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

Fix processing report files with Unicode in pathes. #58

Merged
merged 5 commits into from
Jun 15, 2022

Conversation

thesvistun
Copy link
Contributor

Jenkins replaces some ASCII symbols like colons with Unicode
storing builds data. Parsing reports letter when users open
'SLOCCount Results' window the plugin unable to retrieve
SLOC information - file was stored by path with Unicode.

It relates to JDK 8.
Using unmarshal(File f) indeed proceses not the File but a URL
based on its absolute path. When JDK tries to open connection it
calles ParseUtil.decode(url.getFile()) against our path containing
Unicode. This method converts Unicode back to ASCII. So we get
java.io.FileNotFoundException wrapped in javax.xml.bind.JAXBException,
which is ignored by the plugin. Using unmarshal(java.io.InputStream is)
soleves the issue due to JDK uses passed InputStream and all
described here above do not affect us.

I facing bellow exception in my environment and this commit help me to sovle it.
My environment is:
 - Jenkins 2.190.3
 - Java 11
 - Jaxb plugin installed
I also tried add -Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory to JAVA_OPT but it not work.


2019-11-28 08:46:10.593+0000 [id=51]	WARNING	j.t.i.j.MissingClassTelemetry#reportException: Added a missed class for missing class telemetry. Class: com.sun.xml.internal.bind.v2.ContextFactory
java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
	at jenkins.telemetry.impl.java11.CatcherClassLoader.findClass(CatcherClassLoader.java:47)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122)
	at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:276)
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:421)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662)
	at hudson.plugins.sloccount.model.cloc.ClocReport.parse(ClocReport.java:65)
	at hudson.plugins.sloccount.model.SloccountParser.parse(SloccountParser.java:81)
	at hudson.plugins.sloccount.model.SloccountParser.invoke(SloccountParser.java:48)
	at hudson.plugins.sloccount.model.SloccountParser.invoke(SloccountParser.java:20)
	at hudson.FilePath.act(FilePath.java:1078)
	at hudson.FilePath.act(FilePath.java:1061)
	at hudson.plugins.sloccount.SloccountPublisher.perform(SloccountPublisher.java:87)
	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:79)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1074)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
	at hudson.model.Run.execute(Run.java:1840)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
Jenkins replaces some ASCII symbols like colons with Unicode
storing builds data. Parsing reports letter when users open
'SLOCCount Results' window the plugin unable to retrieve
SLOC information - file was stored by path with Unicode.

It relates to JDK 8.
Using unmarshal(File f) indeed proceses not the File but a URL
based on its absolute path. When JDK tries to open connection it
calles ParseUtil.decode(url.getFile()) against our path containing
Unicode. This method converts Unicode back to ASCII. So we get
java.io.FileNotFoundException wrapped in javax.xml.bind.JAXBException,
which is ignored by the plugin. Using unmarshal(java.io.InputStream is)
soleves the issue due to JDK uses passed InputStream and all
described here above do not affect us.
@thesvistun
Copy link
Contributor Author

Hi @ivaivalous, can you review the PR, please.

Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@basil basil merged commit 16a0199 into jenkinsci:master Jun 15, 2022
@basil
Copy link
Member

basil commented Jun 15, 2022

Released in 1.26.

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

Successfully merging this pull request may close these issues.

3 participants