Skip to content

Commit

Permalink
Merge pull request #78 from iantmoore/glossary-mojo-fix
Browse files Browse the repository at this point in the history
fix for #77 glossary mojo attempting to read a closed jar file
  • Loading branch information
iantmoore committed Dec 16, 2017
2 parents 6e99c2f + 5e09fc4 commit a4bc14b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 34 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Requirements
* Java 8
* Scala 2.12.3 (included)

1.1.4
-----
* Fix for #77 Glossary Builder mojo unable to load step implementation meta information from jars


1.1.3
-----
* Changed the root report page to be index.html. Added a redirect page in for the old.
Expand Down
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.6</version>
<version>1.6.7</version>

<extensions>true</extensions>
<configuration>
Expand All @@ -502,8 +502,7 @@
<javaVersion>r${java.version}</javaVersion>
</tags>

<!-- TODO: Turn back on after first Travis release -->
<autoReleaseAfterClose>false</autoReleaseAfterClose>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,38 +245,50 @@ private List<StepImplementationsDescriptor> getStepTags(HashSet<String> loadedCl

// where is this class ?
final JarFile jarFileForClass = getJarFileForClass(classToDocument);
if (jarFileForClass != null) {

log.debug("loading info from jar");
try {
if (jarFileForClass != null) {

// look for the xml file in the jar, load up from
// there
loadStepTagsFromJar(jarFileForClass, classStepTags, loadedClasses);
} else {
log.debug("loading step info from paths");
// if it's in the project, run the javadoc and collect the
// details
log.debug("loading info from jar");

// TODO - if this class is annotated with AdditionalStepImplementations, lookup those instead..
// look for the xml file in the jar, load up from
// there
loadStepTagsFromJar(jarFileForClass, classStepTags, loadedClasses);
} else {
log.debug("loading step info from paths");
// if it's in the project, run the javadoc and collect the
// details

try {
Class<?> stepImplClass = classRealm.loadClass(classToDocument);
// TODO - if this class is annotated with AdditionalStepImplementations, lookup those instead..

SubSteps.AdditionalStepImplementations additionalStepImpls = stepImplClass.getDeclaredAnnotation(SubSteps.AdditionalStepImplementations.class);
try {
Class<?> stepImplClass = classRealm.loadClass(classToDocument);

if (additionalStepImpls != null) {
for (Class c : additionalStepImpls.value()) {
SubSteps.AdditionalStepImplementations additionalStepImpls = stepImplClass.getDeclaredAnnotation(SubSteps.AdditionalStepImplementations.class);

classStepTags.addAll(runJavaDoclet(c.getCanonicalName()));
if (additionalStepImpls != null) {
for (Class c : additionalStepImpls.value()) {

classStepTags.addAll(runJavaDoclet(c.getCanonicalName()));
}
}
}

} catch (ClassNotFoundException e) {
log.error("failed to load class: " + classToDocument, e);
} catch (ClassNotFoundException e) {
log.error("failed to load class: " + classToDocument, e);

}
}

classStepTags.addAll(runJavaDoclet(classToDocument));
classStepTags.addAll(runJavaDoclet(classToDocument));
}
}
finally {
if (jarFileForClass != null){
try {
jarFileForClass.close();
} catch (IOException e) {
log.debug("ioexcception closing jar file", e);
}
}
}
}
return classStepTags;
Expand Down Expand Up @@ -326,7 +338,6 @@ private void loadStepTagsFromJar(final JarFile jarFileForClass,

if (entry != null) {


try {
final InputStream is = jarFileForClass.getInputStream(entry);
InputStreamReader isr = new InputStreamReader(is);
Expand Down Expand Up @@ -377,15 +388,15 @@ private JarFile getJarFileForClass(final String className) {
} catch (final IOException e) {
log.error("IO Exception opening jar file", e);
}
finally {
if (tempJarFile != null){
try {
tempJarFile.close();
} catch (IOException e) {
log.debug("ioexcception closing jar file", e);
}
}
}
// finally {
// if (tempJarFile != null){
// try {
// tempJarFile.close();
// } catch (IOException e) {
// log.debug("ioexcception closing jar file", e);
// }
// }
// }
}
}
return jarFile;
Expand Down

0 comments on commit a4bc14b

Please sign in to comment.