From 3d0dc7b2048a31e87d978bf53b3f928e8ec4b93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20CROCQUESEL?= <88554524+scrocquesel@users.noreply.github.com> Date: Fri, 10 Feb 2023 15:00:51 +0100 Subject: [PATCH] Revert "Postprocess in temporary files before moving all of them at the same time" This reverts commit 8d01ea5c6a54d786c271c59d4c74530c8afb88da. --- .../grpc/deployment/GrpcPostProcessing.java | 46 +------------------ 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/deployment/GrpcPostProcessing.java b/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/deployment/GrpcPostProcessing.java index ca1131b81efaa..84cf4429aa1b6 100644 --- a/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/deployment/GrpcPostProcessing.java +++ b/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/deployment/GrpcPostProcessing.java @@ -1,14 +1,7 @@ package io.quarkus.grpc.deployment; import java.io.File; -import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.function.Consumer; import org.jboss.logging.Logger; @@ -72,7 +65,6 @@ private boolean isEnabled(CodeGenContext context, String name, boolean def) { public void postprocess() { SourceRoot sr = new SourceRoot(root); - Map changedFiles = new HashMap(); try { sr.parse("", new SourceRoot.Callback() { @Override @@ -84,19 +76,9 @@ public com.github.javaparser.utils.SourceRoot.Callback.Result process(Path local if (unit.getPrimaryType().isPresent()) { TypeDeclaration type = unit.getPrimaryType().get(); postprocess(unit, type); - - // save to a temporary file first, then move all temporary unit files at the same time - try { - unit.setStorage(Files.createTempFile(null, null), - sr.getParserConfiguration().getCharacterEncoding()) - .getStorage().get().save(sr.getPrinter()); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - - changedFiles.put(unit.getStorage().get().getPath(), absolutePath); - return Result.DONT_SAVE; + return Result.SAVE; } + } else { // Compilation issue - report and skip log.errorf( @@ -108,33 +90,9 @@ public com.github.javaparser.utils.SourceRoot.Callback.Result process(Path local return Result.DONT_SAVE; } }); - - changedFiles.entrySet().forEach(new Consumer>() { - @Override - public void accept(Entry entry) { - try { - Files.move(entry.getKey(), entry.getValue(), StandardCopyOption.REPLACE_EXISTING); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - }); - changedFiles.clear(); - } catch (Exception e) { // read issue, report and exit log.error("Unable to parse the classes generated using protoc - skipping gRPC post processing", e); - } finally { - changedFiles.entrySet().forEach(new Consumer>() { - @Override - public void accept(Entry e) { - try { - Files.deleteIfExists(e.getKey()); - } catch (IOException discard) { - // Ignore it. - } - } - }); } }