Skip to content

Commit

Permalink
Improves further variable names 🌟
Browse files Browse the repository at this point in the history
`e` β†’ `exception`
`m` β†’ `matcher`
`props` β†’ `clonedProperties`
`propsOut` β†’ `outputStream`
`propsFile` β†’ `propertiesFile`

#233
  • Loading branch information
jakobvogel committed Sep 18, 2023
1 parent a45dc10 commit 7d6fd11
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions src/main/java/ninja/S3Dispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ private static class S3Request {
builder.add('.' + myself.getHostAddress());
builder.add('.' + myself.getHostName());
builder.add('.' + myself.getCanonicalHostName());
} catch (Exception e) {
} catch (Exception exception) {
// reaching this point, we failed to resolve the local host name. tant pis.
Exceptions.ignore(e);
Exceptions.ignore(exception);
}

DOMAINS = builder.build();
Expand Down Expand Up @@ -351,14 +351,14 @@ private String getAuthHash(WebContext webContext) {
}
String authentication =
Strings.isEmpty(authorizationHeaderValue.getString()) ? "" : authorizationHeaderValue.getString();
Matcher m = AWS_AUTH_PATTERN.matcher(authentication);
if (m.matches()) {
return m.group(2);
Matcher matcher = AWS_AUTH_PATTERN.matcher(authentication);
if (matcher.matches()) {
return matcher.group(2);
}

m = AWS_AUTH4_PATTERN.matcher(authentication);
if (m.matches()) {
return m.group(7);
matcher = AWS_AUTH4_PATTERN.matcher(authentication);
if (matcher.matches()) {
return matcher.group(7);
}

return null;
Expand Down Expand Up @@ -915,13 +915,14 @@ private void startMultipartUpload(WebContext webContext, Bucket bucket, String i
}

private void storePropertiesInUploadDir(Map<String, String> properties, String uploadId) {
Properties props = new Properties();
properties.forEach(props::setProperty);
try (FileOutputStream propsOut = new FileOutputStream(new File(getUploadDir(uploadId),
TEMPORARY_PROPERTIES_FILENAME))) {
props.store(propsOut, "");
} catch (IOException e) {
Exceptions.handle(e);
Properties clonedProperties = new Properties();
properties.forEach(clonedProperties::setProperty);

try (FileOutputStream outputStream = new FileOutputStream(new File(getUploadDir(uploadId),
TEMPORARY_PROPERTIES_FILENAME))) {
clonedProperties.store(outputStream, "");
} catch (IOException exception) {
Exceptions.handle(exception);
}
}

Expand Down Expand Up @@ -958,12 +959,12 @@ private void multiObject(WebContext webContext, String uploadId, String partNumb
.setHeader(HTTP_HEADER_NAME_ETAG, etag)
.addHeader(HttpHeaderNames.ACCESS_CONTROL_EXPOSE_HEADERS, HTTP_HEADER_NAME_ETAG)
.status(HttpResponseStatus.OK);
} catch (IOException e) {
} catch (IOException exception) {
errorSynthesizer.synthesiseError(webContext,
null,
null,
S3ErrorCode.InternalError,
Exceptions.handle(e).getMessage());
Exceptions.handle(exception).getMessage());
}
}

Expand Down Expand Up @@ -999,8 +1000,8 @@ private void completeMultipartUpload(WebContext webContext,
});
try {
reader.parse(in);
} catch (IOException e) {
Exceptions.handle(e);
} catch (IOException exception) {
Exceptions.handle(exception);
}

File file = combineParts(id,
Expand Down Expand Up @@ -1042,8 +1043,8 @@ private void completeMultipartUpload(WebContext webContext,
out.property("Key", id);
out.property(HTTP_HEADER_NAME_ETAG, etag);
out.endOutput();
} catch (IOException e) {
Exceptions.ignore(e);
} catch (IOException exception) {
Exceptions.ignore(exception);
errorSynthesizer.synthesiseError(webContext,
null,
null,
Expand All @@ -1053,9 +1054,9 @@ private void completeMultipartUpload(WebContext webContext,
}

private void commitPropertiesFromUploadDir(String uploadId, StoredObject object) throws IOException {
File propsFile = new File(getUploadDir(uploadId), TEMPORARY_PROPERTIES_FILENAME);
if (propsFile.exists()) {
Files.move(propsFile, object.getPropertiesFile());
File propertiesFile = new File(getUploadDir(uploadId), TEMPORARY_PROPERTIES_FILENAME);
if (propertiesFile.exists()) {
Files.move(propertiesFile, object.getPropertiesFile());
}
}

Expand All @@ -1076,8 +1077,8 @@ private File combineParts(String id, String uploadId, List<File> parts) {
FileChannel outChannel = outStream.getChannel()) {
combine(parts, outChannel);
}
} catch (IOException e) {
throw Exceptions.handle(e);
} catch (IOException exception) {
throw Exceptions.handle(exception);
}

return file;
Expand Down Expand Up @@ -1107,8 +1108,8 @@ private void abortMultipartUpload(WebContext webContext, String uploadId) {
private static void delete(File file) {
try {
sirius.kernel.commons.Files.delete(file.toPath());
} catch (IOException e) {
Exceptions.handle(Storage.LOG, e);
} catch (IOException exception) {
Exceptions.handle(Storage.LOG, exception);
}
}

Expand Down

0 comments on commit 7d6fd11

Please sign in to comment.