Skip to content
Permalink
Browse files
No need to nest in else.
  • Loading branch information
garydgregory committed Mar 5, 2021
1 parent dd4a9ff commit 6edb9914c5e15fc3c8acb9a869b447ca3ce96347
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
@@ -279,13 +279,14 @@ public boolean isInMemory() {
public long getSize() {
if (size >= 0) {
return size;
} else if (cachedContent != null) {
}
if (cachedContent != null) {
return cachedContent.length;
} else if (dfos.isInMemory()) {
}
if (dfos.isInMemory()) {
return dfos.getData().length;
} else {
return dfos.getFile().length();
}
return dfos.getFile().length();
}

/**
@@ -394,27 +395,26 @@ public void write(final File file) throws Exception {
}
} else {
final File outputFile = getStoreLocation();
if (outputFile != null) {
// Save the length of the file
size = outputFile.length();
/*
* The uploaded file is being stored on disk
* in a temporary location so move it to the
* desired file.
*/
if (file.exists() && !file.delete()) {
throw new FileUploadException(
"Cannot write uploaded file to disk!");
}
FileUtils.moveFile(outputFile, file);
} else {
if (outputFile == null) {
/*
* For whatever reason we cannot write the
* file to disk.
*/
throw new FileUploadException(
"Cannot write uploaded file to disk!");
}
// Save the length of the file
size = outputFile.length();
/*
* The uploaded file is being stored on disk
* in a temporary location so move it to the
* desired file.
*/
if (file.exists() && !file.delete()) {
throw new FileUploadException(
"Cannot write uploaded file to disk!");
}
FileUtils.moveFile(outputFile, file);
}
}

@@ -122,14 +122,13 @@ public static String decodeText(final String text) throws UnsupportedEncodingExc
while (offset < endOffset) {
// step over the white space characters.
ch = text.charAt(offset);
if (LINEAR_WHITESPACE.indexOf(ch) != -1) { // whitespace found
offset++;
} else {
if (LINEAR_WHITESPACE.indexOf(ch) == -1) {
// record the location of the first non lwsp and drop down to process the
// token characters.
endWhiteSpace = offset;
break;
}
offset++;
}
} else {
// we have a word token. We need to scan over the word and then try to parse it.
@@ -138,11 +137,10 @@ public static String decodeText(final String text) throws UnsupportedEncodingExc
while (offset < endOffset) {
// step over the non white space characters.
ch = text.charAt(offset);
if (LINEAR_WHITESPACE.indexOf(ch) == -1) { // not white space
offset++;
} else {
if (LINEAR_WHITESPACE.indexOf(ch) != -1) {
break;
}
offset++;

//NB: Trailing whitespace on these header strings will just be discarded.
}
@@ -595,9 +595,8 @@ public ServletContext getServletContext() {
final HttpSession session = getSession();
if (session == null) {
return null;
} else {
return session.getServletContext();
}
return session.getServletContext();
}

@Override

0 comments on commit 6edb991

Please sign in to comment.