[
https://issues.apache.org/jira/browse/MNG-7945?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17789827#comment-17789827
]
ASF GitHub Bot commented on MNG-7945:
-------------------------------------
gnodet commented on code in PR #1323:
URL: https://github.com/apache/maven/pull/1323#discussion_r1405442816
##########
maven-core/src/main/java/org/apache/maven/internal/transformation/TransformedArtifact.java:
##########
@@ -67,36 +71,36 @@ public void setFile(File file) {
@Override
public File getFile() {
- Path result = onChangeTransformer.get();
- if (result == null) {
- return null;
+ try {
+ Path result = onChangeTransformer.transform();
+ if (result == null) {
+ return null;
+ }
+ return result.toFile();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
- return result.toFile();
}
private static final int BUFFER_SIZE = 8192;
- private static String sha1(Path path) {
- try {
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- try (InputStream fis = Files.newInputStream(path)) {
- byte[] buffer = new byte[BUFFER_SIZE];
- int read;
- while ((read = fis.read(buffer)) != -1) {
- md.update(buffer, 0, read);
- }
- }
- StringBuilder result = new StringBuilder();
- for (byte b : md.digest()) {
- result.append(String.format("%02x", b));
+ private static String sha1(Path path) throws Exception {
+ MessageDigest md = MessageDigest.getInstance("SHA-1");
+ try (InputStream fis = Files.newInputStream(path)) {
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int read;
+ while ((read = fis.read(buffer)) != -1) {
+ md.update(buffer, 0, read);
}
- return result.toString();
- } catch (Exception e) {
- throw new RuntimeException(e);
}
+ StringBuilder result = new StringBuilder();
+ for (byte b : md.digest()) {
+ result.append(String.format("%02x", b));
+ }
+ return result.toString();
}
- protected abstract void transform(Path src, Path dst);
+ protected abstract void transform(Path src, Path dst) throws Exception;
Review Comment:
That forces the definition of lots of exceptions, just for the sake of
avoiding `throws Exception`. I think I don't really agree to this.
Anyway, I refactored the whole package to avoid exception chaining and
everything is caught in a public specific exception.
> Fix profile settings being injected into consumer POMs
> ------------------------------------------------------
>
> Key: MNG-7945
> URL: https://issues.apache.org/jira/browse/MNG-7945
> Project: Maven
> Issue Type: Bug
> Affects Versions: 4.0.0-alpha-8
> Reporter: Tamas Cservenak
> Assignee: Guillaume Nodet
> Priority: Major
> Fix For: 4.0.0-alpha-9
>
>
> The consumer POMs may end up containing information from user settings.
> The reason is that they are currently built from the effective POMs. They
> need to be rebuilt based on raw models.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)