Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavassistProxyFactory fails if it cannot write to /tmp/com/zaxxer/.../*.class #124

Closed
xkr47 opened this issue Jul 28, 2014 · 7 comments
Closed

Comments

@xkr47
Copy link
Contributor

xkr47 commented Jul 28, 2014

It seems JavassistProxyFactory dumps generated proxy classes to a directory structure directly below the operating system tmp directory. At least in Unix environments this directory is typically shared, so if another user tries to use HikariCP as well, he gets an exception when failing to overwrite the files dumped by the first user.

Perhaps the path where temporary files are written (by HikariCP) could be made user-specific e.g. adding System.getProperty("user.name") into the path, to allow multiple users to use HikariCP on the same machine?

Sample stacktrace snippet:

java.lang.ExceptionInInitializerError: null
        at com.zaxxer.hikari.HikariConfig.<clinit>(HikariConfig.java:86) ~[sb-consumer-SNAPSHOT.1.jar:na]
        ...
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.io.FileNotFoundException: /tmp/com/zaxxer/hikari/proxy/ConnectionJavassistProxy.class (Permission denied)
        at com.zaxxer.hikari.proxy.JavassistProxyFactory.<clinit>(JavassistProxyFactory.java:60) ~[sb-consumer-SNAPSHOT.1.jar:na]
        ... 97 common frames omitted
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.io.FileNotFoundException: /tmp/com/zaxxer/hikari/proxy/ConnectionJavassistProxy.class (Permission denied)
        at com.zaxxer.hikari.proxy.JavassistProxyFactory.<init>(JavassistProxyFactory.java:97) ~[sb-consumer-SNAPSHOT.1.jar:na]
        at com.zaxxer.hikari.proxy.JavassistProxyFactory.<clinit>(JavassistProxyFactory.java:55) ~[sb-consumer-SNAPSHOT.1.jar:na]
        ... 97 common frames omitted
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: /tmp/com/zaxxer/hikari/proxy/ConnectionJavassistProxy.class (Permission denied)
        at javassist.CtClass.debugWriteFile(CtClass.java:1478) ~[sb-consumer-SNAPSHOT.1.jar:na]
        at com.zaxxer.hikari.proxy.JavassistProxyFactory.generateProxyClass(JavassistProxyFactory.java:189) ~[sb-consumer-SNAPSHOT.1.jar:na]
        at com.zaxxer.hikari.proxy.JavassistProxyFactory.<init>(JavassistProxyFactory.java:85) ~[sb-consumer-SNAPSHOT.1.jar:na]
        ... 98 common frames omitted
Caused by: java.io.FileNotFoundException: /tmp/com/zaxxer/hikari/proxy/ConnectionJavassistProxy.class (Permission denied)
        at java.io.FileOutputStream.open(Native Method) ~[na:1.7.0_60]
        at java.io.FileOutputStream.<init>(FileOutputStream.java:221) ~[na:1.7.0_60]
        at java.io.FileOutputStream.<init>(FileOutputStream.java:110) ~[na:1.7.0_60]
        at javassist.CtClass$DelayedFileOutputStream.init(CtClass.java:1493) ~[sb-consumer-SNAPSHOT.1.jar:na]
        at javassist.CtClass$DelayedFileOutputStream.close(CtClass.java:1518) ~[sb-consumer-SNAPSHOT.1.jar:na]
        at java.io.FilterOutputStream.close(FilterOutputStream.java:160) ~[na:1.7.0_60]
        at java.io.FilterOutputStream.close(FilterOutputStream.java:160) ~[na:1.7.0_60]
        at javassist.CtClass.writeFile(CtClass.java:1431) ~[sb-consumer-SNAPSHOT.1.jar:na]
        at javassist.CtClass.debugWriteFile(CtClass.java:1473) ~[sb-consumer-SNAPSHOT.1.jar:na]
        ... 100 common frames omitted
@xkr47 xkr47 changed the title JavassistProxyFactory fails if it cannot write to temporary /tmp/com/zaxxer/.../*.class JavassistProxyFactory fails if it cannot write to /tmp/com/zaxxer/.../*.class Jul 28, 2014
@holgerstolzenberg
Copy link

I think that configuring the base path for writing the tmp files should be considered also.

@chrisvest
Copy link

I think these classes should be held entirely in memory, unless a flag for debugging proxy class generation says otherwise.

@holgerstolzenberg
Copy link

Also agree on that. Not sure though if in-memory persistence may yield other problems (heap consumption).

@brettwooldridge
Copy link
Owner

Classes are only dumped to the tmp dir when DEBUG level logging is set -- dumping the classes is not operational, but is in fact used for debugging. There are three options here:

  • Turn off DEBUG level logging (typically not used in production)
  • Turn off DEBUG level logging for the class JavassistProxyFactory
  • Set the java.io.tmpdir directory (system property) to wherever you would like the temporary files to be written

@xkr47
Copy link
Contributor Author

xkr47 commented Jul 29, 2014

Ok, turning off DEBUG logging for JavassistProxyFactory sounds like the best option for us, thanks!

@xkr47
Copy link
Contributor Author

xkr47 commented Jul 29, 2014

Perhaps it would still be nice for those actually using the dumping feature that the files would be in a user-specific directory?

@brettwooldridge
Copy link
Owner

It's really just for internal use. We're going to change it over to an internally defined system property rather than triggering off of the debug mode of the logger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants