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

[Java][jersey2] Fix logging for jersey2 (Java6) #7348

Merged

Conversation

SergeyLyakhov
Copy link
Contributor

PR checklist

[+] Read the contribution guidelines.
[+] Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
[-] Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
Committed it into master branch, because expect this fix in 2.4.0. May create PR for 3.0 as well.

[+] Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
@bbdouglas @JFCote @sreeshas @jfiala @lukoyanov @cbornet @wing328

Description of the PR

Jersey 2.6 (used with Java6) doesn't support LoggingFeature (fix SHA-1: 2d19776

  • Merge branch 'mobreza-jersey-logging-deprecated' ).
    This change reverts to the old logging logic for Jersey2 + java6.

@SergeyLyakhov
Copy link
Contributor Author

@wing328
This is one of fixes required for PR #7060 to pass test checks (other build issues are listed in #7060).
However I don't understand how this PR test was completed successfully, while #7060 - not.

@SergeyLyakhov
Copy link
Contributor Author

SergeyLyakhov commented Jan 9, 2018

@wing328
Also, do not understand how such fixes will be migrated to other branches. I suppose it is not possible to merge/cherry-pick changes in samples automatically. Should I perform any additional steps to add such changes into 2.4.0/3.0.0 branches?

@wing328
Copy link
Contributor

wing328 commented Jan 9, 2018

@SergeyLyakhov We'll sync the change in master to those branches (2.4.0, 3.0.0) later

clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
// Set logger to ALL
java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL);
{{/supportJava6}}
{{#supportJava6}}
clientConfig.register(new LoggingFilter(java.util.logging.Logger.getLogger(LoggingFilter.class.getName()), true));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please align this line properly by removing 2 spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@wing328
Copy link
Contributor

wing328 commented Jan 11, 2018

@SergeyLyakhov thanks again for the PR. When I tried to test samples/client/petstore/java/jersey2-java6 with Java6, I got the following errors:

0.24s$ cd samples/client/petstore/java/jersey2-java6/ && mvn test
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:648)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:272)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:68)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:207)

Ref: https://travis-ci.org/swagger-api/swagger-codegen/builds/327592947

Did you get similar result when running mvn test locally in your Java6 environment?

@SergeyLyakhov
Copy link
Contributor Author

@wing328
This is byte code incompatibility version error.
Probably it occurred because you run mvn test with JRE6 (this is correct for test env), but project was built with more major version of JDK (7/8/9).
There are source|target parameters in javac / maven-compiler-plugin - https://stackoverflow.com/questions/15492948/javac-source-and-target-options.
In jersey2 project for "java6" it is 1.7 (both source and target).
"source" should be changed from 1.7 to 1.6 (for "java6") in pom and gradle (sbt script missed these settings).
"target" should be either changed in same way, or removed (in this case default version of javac will be used). If target removed - you need compile and test "java6" with the same version of JDK.

Will update PR tomorrow if you agree with proposed changes.

@wing328
Copy link
Contributor

wing328 commented Jan 12, 2018

@wing328 wing328 merged commit 4241b11 into swagger-api:master Jan 12, 2018
@wing328
Copy link
Contributor

wing328 commented Jan 12, 2018

@SergeyLyakhov I've merged your fix into master.

If you later can find a way to make it work with mvn test, please file another PR.

@wing328 wing328 changed the title [Java][jersey2] Fix logging for jersey2 + java6 (#6715). [Java][jersey2] Fix logging for jersey2 + java6 Jan 13, 2018
@wing328 wing328 changed the title [Java][jersey2] Fix logging for jersey2 + java6 [Java][jersey2] Fix logging for jersey2 (Java6) Jan 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants