Andrea Campanella
Committed by Gerrit Code Review

ONOS-3530 Fix array out of bounds in case of no @param value description

Change-Id: I336a7645547f844e11ab08cc3cf9f403fa42d890
......@@ -54,6 +54,7 @@
<module>tools/package/archetypes</module>
<module>tools/package/branding</module>
<module>tools/package/maven-plugin</module>
</modules>
<url>http://onosproject.org/</url>
......@@ -79,6 +80,7 @@
<copycat.version>0.5.0.onos</copycat.version>
<!-- FIXME update to release version before Emu release -->
<openflowj.version>0.9.2.onos-SNAPSHOT</openflowj.version>
<onos-maven-plugin.version>1.7-SNAPSHOT</onos-maven-plugin.version>
<karaf.version>3.0.3</karaf.version>
<jersey.version>1.19</jersey.version>
</properties>
......@@ -654,7 +656,7 @@
<plugin>
<groupId>org.onosproject</groupId>
<artifactId>onos-maven-plugin</artifactId>
<version>1.6</version>
<version>${onos-maven-plugin.version}</version>
<executions>
<execution>
<id>cfg</id>
......
......@@ -293,7 +293,7 @@ public class OnosSwaggerMojo extends AbstractMojo {
+ param + ".json");
String lines = Files.readLines(config, Charsets.UTF_8).stream().reduce((t, u) -> t + u).
get();
lines = lines.replaceAll("\\s+","");
lines = lines.replaceAll("\\s+", "");
definitions.putPOJO(param, lines);
} catch (IOException e) {
e.printStackTrace();
......@@ -352,7 +352,7 @@ public class OnosSwaggerMojo extends AbstractMojo {
private String getIOType(JavaAnnotation annotation) {
if (annotation.getNamedParameter("value").toString().equals(JSON)) {
return "application/json";
} else if (annotation.getNamedParameter("value").toString().equals(OCTET_STREAM)){
} else if (annotation.getNamedParameter("value").toString().equals(OCTET_STREAM)) {
return "application/octet_stream";
}
return "";
......@@ -408,15 +408,21 @@ public class OnosSwaggerMojo extends AbstractMojo {
}
for (DocletTag p : javaMethod.getTagsByName("param")) {
if (p.getValue().contains(annotationName)) {
try {
String description = p.getValue().split(" ", 2)[1].trim();
String description = "";
if (p.getValue().split(" ", 2).length >= 2) {
description = p.getValue().split(" ", 2)[1].trim();
if (description.contains("optional")) {
required = false;
}
individualParameterNode.put("description", description);
} catch (Exception e) {
e.printStackTrace();
} else {
getLog().warn(String.format(
"No description for parameter \"%s\" in " +
"method \"%s\" in %s (line %d)",
p.getValue(), javaMethod.getName(),
javaMethod.getDeclaringClass().getName(),
javaMethod.getLineNumber()));
}
individualParameterNode.put("description", description);
}
}
individualParameterNode.put("required", required);
......