Skip to content
Permalink
Browse files
FILEUPLOAD-344 - Check final variable checkstyle. (#114)
  • Loading branch information
arturobernalg committed Sep 19, 2021
1 parent 1deeae4 commit 538410d3ccf5fef19780da59e8827bc59eb8bd9e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 9 deletions.
22 pom.xml
@@ -287,6 +287,28 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>validate-main</id>
<phase>validate</phase>
<configuration>
<configLocation>${basedir}/src/checkstyle/fileupload_checks.xml</configLocation>
<suppressionsLocation>${basedir}/src/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
<enableRulesSummary>false</enableRulesSummary>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<goals>
<goal>checkstyle</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
@@ -94,9 +94,13 @@
<property name="ignorePattern" value="^ \* @version .*$"/>
</module>


<module name="TreeWalker">

<module name="FinalLocalVariable">
<property name="tokens" value="VARIABLE_DEF,PARAMETER_DEF"/>
<property name="validateEnhancedForLoopVariable" value="true"/>
</module>

<!-- Allow comments to suppress checks -->
<module name="SuppressionCommentFilter"/>

@@ -346,7 +346,7 @@ public Map<String, List<FileItem>> parseParameterMap(final RequestContext ctx)

for (final FileItem fileItem : items) {
final String fieldName = fileItem.getFieldName();
List<FileItem> mappedItems = itemsMap.computeIfAbsent(fieldName, k -> new ArrayList<>());
final List<FileItem> mappedItems = itemsMap.computeIfAbsent(fieldName, k -> new ArrayList<>());

mappedItems.add(fileItem);
}
@@ -374,7 +374,7 @@ public byte[] getBoundary(final String contentType) {
if (boundaryStr == null) {
return null;
}
byte[] boundary;
final byte[] boundary;
boundary = boundaryStr.getBytes(StandardCharsets.ISO_8859_1);
return boundary;
}
@@ -451,7 +451,7 @@ public byte readByte() throws IOException {
public boolean readBoundary()
throws FileUploadIOException, MalformedStreamException {
final byte[] marker = new byte[2];
boolean nextChunk;
final boolean nextChunk;

head += boundaryLength;
try {
@@ -308,11 +308,11 @@ public byte[] get() throws UncheckedIOException {
return cachedContent != null ? cachedContent.clone() : new byte[0];
}

byte[] fileData = new byte[(int) getSize()];
final byte[] fileData = new byte[(int) getSize()];

try (InputStream fis = Files.newInputStream(dfos.getFile().toPath())) {
IOUtils.readFully(fis, fileData);
} catch (IOException e) {
} catch (final IOException e) {
throw new UncheckedIOException(e);
}
return fileData;
@@ -348,7 +348,7 @@ public String getString(final String charset)
@Override
public String getString() {
try {
byte[] rawData = get();
final byte[] rawData = get();
String charset = getCharSet();
if (charset == null) {
charset = defaultCharset;
@@ -384,7 +384,7 @@ public void write(final File file) throws Exception {
if (isInMemory()) {
try (OutputStream fout = Files.newOutputStream(file.toPath())) {
fout.write(get());
} catch (IOException e) {
} catch (final IOException e) {
throw new IOException("Unexpected output data");
}
} else {
@@ -87,7 +87,8 @@ public Iterator<String> getHeaders(final String name) {
*/
public synchronized void addHeader(final String name, final String value) {
final String nameLower = name.toLowerCase(Locale.ENGLISH);
List<String> headerValueList = headerNameToValueListMap.computeIfAbsent(nameLower, k -> new ArrayList<>());
final List<String> headerValueList = headerNameToValueListMap.
computeIfAbsent(nameLower, k -> new ArrayList<>());
headerValueList.add(value);
}

0 comments on commit 538410d

Please sign in to comment.