Skip to content

Commit

Permalink
Merge pull request #1114 from amvanbaren/java-useless-curly-braces
Browse files Browse the repository at this point in the history
Remove useless curly braces around statement
  • Loading branch information
amvanbaren authored Feb 14, 2025
2 parents 74a19a3 + 490671f commit 839e34a
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ public ResponseEntity<StreamingResponseBody> extractData(ClientHttpResponse resp
var json = proxy.rewriteUrls(mapper.readTree(response.getBody()));
return ResponseEntity.status(statusCode)
.headers(headers)
.body(outputStream -> {
mapper.writeValue(outputStream, json);
});
.body(outputStream -> mapper.writeValue(outputStream, json));
} else {
var tempFile = new TempFile("browse", null);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,11 @@ public List<SitemapRow> fetchSitemapRows() {
.join(EXTENSION).on(EXTENSION.NAMESPACE_ID.eq(NAMESPACE.ID))
.where(EXTENSION.ACTIVE.eq(true))
.fetch()
.map(row -> {
return new SitemapRow(
row.get(NAMESPACE.NAME),
row.get(EXTENSION.NAME),
row.get(LAST_UPDATED)
);
});
.map(row -> new SitemapRow(
row.get(NAMESPACE.NAME),
row.get(EXTENSION.NAME),
row.get(LAST_UPDATED)
));
}

public List<String> findActiveExtensionNames(Namespace namespace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public SecurityFilterChain filterChain(HttpSecurity http, OAuth2UserServices use
.authenticated()
)
.cors(configurer -> configurer.configure(http))
.csrf(configurer -> {
configurer.ignoringRequestMatchers(antMatchers("/api/-/publish", "/api/-/namespace/create", "/api/-/query", "/vscode/**"));
})
.csrf(configurer -> configurer.ignoringRequestMatchers(antMatchers("/api/-/publish", "/api/-/namespace/create", "/api/-/query", "/vscode/**")))
.exceptionHandling(configurer -> configurer.authenticationEntryPoint(new Http403ForbiddenEntryPoint()));

if(userServices.canLogin()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ public Path getCachedFile(FileResource resource) {
}

var path = filesCacheKeyGenerator.generateCachedExtensionPath(resource);
FileUtil.writeSync(path, p -> {
getContainerClient().getBlobClient(blobName).downloadToFile(p.toAbsolutePath().toString());
});
FileUtil.writeSync(path, p -> getContainerClient().getBlobClient(blobName).downloadToFile(p.toAbsolutePath().toString()));
return path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@ public void persistProcessedItem(String name, LocalDateTime processedOn, int exe
}

public Map<Long, Integer> processDownloadCounts(Map<String, Integer> files) {
return Observation.createNotStarted("AzureDownloadCountProcessor#processDownloadCounts", observations).observe(() -> {
return repositories.findDownloadsByStorageTypeAndName(STORAGE_AZURE, files.keySet()).stream()
.map(fileResource -> Map.entry(fileResource, files.get(fileResource.getName().toUpperCase())))
.collect(Collectors.groupingBy(
e -> e.getKey().getExtension().getExtension().getId(),
Collectors.summingInt(Map.Entry::getValue)
));
});
return Observation.createNotStarted("AzureDownloadCountProcessor#processDownloadCounts", observations).observe(() -> repositories.findDownloadsByStorageTypeAndName(STORAGE_AZURE, files.keySet()).stream()
.map(fileResource -> Map.entry(fileResource, files.get(fileResource.getName().toUpperCase())))
.collect(Collectors.groupingBy(
e -> e.getKey().getExtension().getExtension().getId(),
Collectors.summingInt(Map.Entry::getValue)
)));
}

@Transactional
Expand All @@ -94,13 +92,11 @@ public List<Extension> increaseDownloadCounts(Map<Long, Integer> extensionDownlo

@Transactional //needs transaction for lazy-loading versions
public void evictCaches(List<Extension> extensions) {
Observation.createNotStarted("AzureDownloadCountProcessor#evictCaches", observations).observe(() -> {
extensions.forEach(extension -> {
extension = entityManager.merge(extension);
cache.evictExtensionJsons(extension);
cache.evictLatestExtensionVersion(extension);
});
});
Observation.createNotStarted("AzureDownloadCountProcessor#evictCaches", observations).observe(() -> extensions.forEach(extension -> {
extension = entityManager.merge(extension);
cache.evictExtensionJsons(extension);
cache.evictLatestExtensionVersion(extension);
}));
}

public void updateSearchEntries(List<Extension> extensions) {
Expand All @@ -120,8 +116,6 @@ public void updateSearchEntries(List<Extension> extensions) {
}

public List<String> processedItems(List<String> blobNames) {
return Observation.createNotStarted("AzureDownloadCountProcessor#processedItems", observations).observe(() -> {
return repositories.findAllSucceededAzureDownloadCountProcessedItemsByNameIn(blobNames);
});
return Observation.createNotStarted("AzureDownloadCountProcessor#processedItems", observations).observe(() -> repositories.findAllSucceededAzureDownloadCountProcessedItemsByNameIn(blobNames));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,11 @@ private Map<String, Integer> processBlobItem(String blobName) {
throw new RuntimeException(e);
}
})
.filter(node -> {
return isGetBlobOperation(node)
&& isStatusOk(node)
&& isExtensionPackageUri(node)
&& isNotOpenVSXUserAgent(node);
}).map(node -> {
.filter(node -> isGetBlobOperation(node)
&& isStatusOk(node)
&& isExtensionPackageUri(node)
&& isNotOpenVSXUserAgent(node))
.map(node -> {
var uri = node.get("uri").asText();
var pathParams = uri.substring(storageServiceEndpoint.length()).split("/");
return Map.entry(pathParams, node.get("time").asText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,7 @@ public Path getCachedFile(FileResource resource) {

var objectId = getObjectId(resource);
var path = filesCacheKeyGenerator.generateCachedExtensionPath(resource);
FileUtil.writeSync(path, p -> {
getStorage().downloadTo(BlobId.of(bucketId, objectId), p);
});

FileUtil.writeSync(path, p -> getStorage().downloadTo(BlobId.of(bucketId, objectId), p));
return path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,18 @@ public OpenApiCustomizer addRateLimitResponse() {
"X-Rate-Limit-Remaining", limitRemainingHeader
));

return openApi -> {
openApi.getPaths().forEach((path, item) -> {
Stream.of(
item.getGet(),
item.getHead(),
item.getPost(),
item.getPut(),
item.getDelete(),
item.getOptions(),
item.getTrace(),
item.getPatch()
)
.filter(Objects::nonNull)
.forEach(operation -> {
var responses = operation.getResponses();
if(responses == null) {
responses = new ApiResponses();
}
return openApi -> openApi.getPaths()
.forEach((path, item) -> item.readOperations()
.forEach(operation -> {
var responses = operation.getResponses();
if(responses == null) {
responses = new ApiResponses();
}

responses.addApiResponse("429", response);
operation.setResponses(responses);
});
});
};
responses.addApiResponse("429", response);
operation.setResponses(responses);
})
);
}

@Bean
Expand Down

0 comments on commit 839e34a

Please sign in to comment.