You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Pankraz76 (via GitHub)" <gi...@apache.org> on 2025/05/22 08:51:31 UTC
[PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Pankraz76 opened a new pull request, #2376:
URL: https://github.com/apache/maven/pull/2376
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on PR #2376:
URL: https://github.com/apache/maven/pull/2376#issuecomment-2904664576
dont we have test for this lock? afaik the lock only gets closed but not like open or checked if its ready to go. So calling this should do the trick as well:
`getProjectLock(session, mojoDescriptor).lock();`
- https://github.com/apache/maven/pull/2384/files#r2104747698
- https://github.com/apache/maven/pull/2384
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2104650114
##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java:
##########
@@ -306,7 +306,7 @@ private void doExecute(MavenSession session, MojoExecution mojoExecution, Depend
ensureDependenciesAreResolved(mojoDescriptor, session, dependencyContext);
- try (NoExceptionCloseable lock = getProjectLock(session, mojoDescriptor)) {
+ try (NoExceptionCloseable ignore = getProjectLock(session, mojoDescriptor)) {
Review Comment:
It is used implicitly by the "try with resource" constructor. The `lock` name is fine, as it is a meaningful name if a future version decides to use it explicitly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on PR #2376:
URL: https://github.com/apache/maven/pull/2376#issuecomment-2904493186
It is used implicitly in a implicit `finally` block, even if we don't see it in the code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2104723298
##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java:
##########
@@ -306,7 +306,7 @@ private void doExecute(MavenSession session, MojoExecution mojoExecution, Depend
ensureDependenciesAreResolved(mojoDescriptor, session, dependencyContext);
- try (NoExceptionCloseable lock = getProjectLock(session, mojoDescriptor)) {
+ try (NoExceptionCloseable ignore = getProjectLock(session, mojoDescriptor)) {
Review Comment:
set dedicate this:
- https://github.com/apache/maven/pull/2384
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet closed pull request #2376: chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField)
URL: https://github.com/apache/maven/pull/2376
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on PR #2376:
URL: https://github.com/apache/maven/pull/2376#issuecomment-2904647915
> It is used implicitly in a implicit `finally` block, even if we don't see it in the code.
yes, then it should be named accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2103910930
##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java:
##########
@@ -306,7 +306,7 @@ private void doExecute(MavenSession session, MojoExecution mojoExecution, Depend
ensureDependenciesAreResolved(mojoDescriptor, session, dependencyContext);
- try (NoExceptionCloseable lock = getProjectLock(session, mojoDescriptor)) {
+ try (NoExceptionCloseable ignore = getProjectLock(session, mojoDescriptor)) {
Review Comment:
really? Show you IDE screen not point out the same:
Looks like a bug in maven to me.
<img width="1331" alt="image" src="https://github.com/user-attachments/assets/d5fc78b9-51e8-435b-97b1-b7724b2ccd62" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2104757933
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -303,7 +301,7 @@ private Properties read(File touchfile) {
Properties props = new Properties();
try (FileInputStream in = new FileInputStream(touchfile)) {
- try (FileLock lock = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
+ try (FileLock ignored = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
Review Comment:
@desruisseaux point out correctly that its used `indirectly`, having the implizit `close()` call.
As IDEA and PMD both point this out is seems ok to rename to give proper context. Its ignored as handled by default.
Other way should be an inline comment for suppression.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2103907588
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -303,7 +301,7 @@ private Properties read(File touchfile) {
Properties props = new Properties();
try (FileInputStream in = new FileInputStream(touchfile)) {
- try (FileLock lock = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
Review Comment:
the block is super small, its **defacto** unused.
<img width="1137" alt="image" src="https://github.com/user-attachments/assets/130bce87-a928-4ede-bf4e-bef2e88a50c7" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2105403040
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -303,7 +301,7 @@ private Properties read(File touchfile) {
Properties props = new Properties();
try (FileInputStream in = new FileInputStream(touchfile)) {
- try (FileLock lock = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
+ try (FileLock ignored = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
Review Comment:
It's used by the try with resources auto-close. See https://stackoverflow.com/questions/70773389/try-with-resource-without-declaring-variable
Unless you can remove the variable, PMD is wrong that this is unused. Maybe Idea is too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2102767750
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -50,8 +50,6 @@ public class DefaultUpdateCheckManager extends AbstractLogEnabled implements Upd
private static final String ERROR_KEY_SUFFIX = ".error";
- public DefaultUpdateCheckManager() {}
Review Comment:
Another reason for keeping this constructor is that this class is annotated with `@Named` and `@Singleton`. So there is chances that this constructor is invoked by reflection, even if the IDE reports no usage of this constructor.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2103910930
##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java:
##########
@@ -306,7 +306,7 @@ private void doExecute(MavenSession session, MojoExecution mojoExecution, Depend
ensureDependenciesAreResolved(mojoDescriptor, session, dependencyContext);
- try (NoExceptionCloseable lock = getProjectLock(session, mojoDescriptor)) {
+ try (NoExceptionCloseable ignore = getProjectLock(session, mojoDescriptor)) {
Review Comment:
really? Show you´r IDE screen not point out the same:
Looks like a bug in maven to me.
<img width="1331" alt="image" src="https://github.com/user-attachments/assets/d5fc78b9-51e8-435b-97b1-b7724b2ccd62" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on PR #2376:
URL: https://github.com/apache/maven/pull/2376#issuecomment-2904638784
idk this is not how java works. The scope of the field `lock` is limited to the block `{}`. not reachable in `final` or `catch`
<img width="915" alt="image" src="https://github.com/user-attachments/assets/accca27e-eb1d-4c46-b2c1-ba7641d244cf" />
its 2 different kind: just see highligh:
<img width="1024" alt="image" src="https://github.com/user-attachments/assets/b2175ea7-f996-4c35-9a32-3be819340eb7" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2104650114
##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java:
##########
@@ -306,7 +306,7 @@ private void doExecute(MavenSession session, MojoExecution mojoExecution, Depend
ensureDependenciesAreResolved(mojoDescriptor, session, dependencyContext);
- try (NoExceptionCloseable lock = getProjectLock(session, mojoDescriptor)) {
+ try (NoExceptionCloseable ignore = getProjectLock(session, mojoDescriptor)) {
Review Comment:
It is used implicitly by the "try with resource" construction. The `lock` name is fine, as it is a meaningful name if a future version decides to use it explicitly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2105417902
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -303,7 +301,7 @@ private Properties read(File touchfile) {
Properties props = new Properties();
try (FileInputStream in = new FileInputStream(touchfile)) {
- try (FileLock lock = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
+ try (FileLock ignored = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
Review Comment:
indeed. This is the only use, which is an exception of the normal pattern (using is explizit).
To make this clear the convention seems naming it `ignroed`, at least considering IDEA and PMD, both recognize the variable as marked explizit, as only used implicit.
Now using the resource which the statement is all about, seems like an error, thats why its pointes out by these tools.
Im altho wondering why its not used, allowing a comment to explain too.
Then the comment end up in the code again, to be self explaining.
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -303,7 +301,7 @@ private Properties read(File touchfile) {
Properties props = new Properties();
try (FileInputStream in = new FileInputStream(touchfile)) {
- try (FileLock lock = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
+ try (FileLock ignored = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
Review Comment:
indeed. This is the only use, which is an exception of the normal pattern (using is explizit).
To make this clear the convention seems naming it `ignored`, at least considering IDEA and PMD, both recognize the variable as marked explizit, as only used implicit.
Now using the resource which the statement is all about, seems like an error, thats why its pointes out by these tools.
Im altho wondering why its not used, allowing a comment to explain too.
Then the comment end up in the code again, to be self explaining.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2103907689
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -303,7 +301,7 @@ private Properties read(File touchfile) {
Properties props = new Properties();
try (FileInputStream in = new FileInputStream(touchfile)) {
- try (FileLock lock = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
+ try (FileLock ignored = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
Review Comment:
really? check out the usage. It seems **unused**.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2102736286
##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java:
##########
@@ -306,7 +306,7 @@ private void doExecute(MavenSession session, MojoExecution mojoExecution, Depend
ensureDependenciesAreResolved(mojoDescriptor, session, dependencyContext);
- try (NoExceptionCloseable lock = getProjectLock(session, mojoDescriptor)) {
+ try (NoExceptionCloseable ignore = getProjectLock(session, mojoDescriptor)) {
Review Comment:
Yes, looks like a bug in PMD
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -50,8 +50,6 @@ public class DefaultUpdateCheckManager extends AbstractLogEnabled implements Upd
private static final String ERROR_KEY_SUFFIX = ".error";
- public DefaultUpdateCheckManager() {}
Review Comment:
don't change the API
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -303,7 +301,7 @@ private Properties read(File touchfile) {
Properties props = new Properties();
try (FileInputStream in = new FileInputStream(touchfile)) {
- try (FileLock lock = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
+ try (FileLock ignored = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
Review Comment:
It's not ignored. Is PMD simply wrong here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2103909260
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -50,8 +50,6 @@ public class DefaultUpdateCheckManager extends AbstractLogEnabled implements Upd
private static final String ERROR_KEY_SUFFIX = ".error";
- public DefaultUpdateCheckManager() {}
Review Comment:
extract thin into dedicated pr just wanted to give attention.
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -50,8 +50,6 @@ public class DefaultUpdateCheckManager extends AbstractLogEnabled implements Upd
private static final String ERROR_KEY_SUFFIX = ".error";
- public DefaultUpdateCheckManager() {}
Review Comment:
extract into dedicated pr just wanted to give attention.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2104702849
##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java:
##########
@@ -306,7 +306,7 @@ private void doExecute(MavenSession session, MojoExecution mojoExecution, Depend
ensureDependenciesAreResolved(mojoDescriptor, session, dependencyContext);
- try (NoExceptionCloseable lock = getProjectLock(session, mojoDescriptor)) {
+ try (NoExceptionCloseable ignore = getProjectLock(session, mojoDescriptor)) {
Review Comment:
declaring something not used is misleading.
Its just "used" in terms of resource handling, but not
Then simply remove the overhead not needed:
<img width="1148" alt="image" src="https://github.com/user-attachments/assets/ef738267-e474-4549-bd61-4083935146f4" />
We would expect some interaction with the field like:
```java
try (NoExceptionCloseable lock = getProjectLock(session, mojoDescriptor)) {
lock.close();
doExecute2(session, mojoExecution);
} finally {
for (MavenProject forkedProject : forkedProjects) {
forkedProject.setExecutionProject(null);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2104702849
##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java:
##########
@@ -306,7 +306,7 @@ private void doExecute(MavenSession session, MojoExecution mojoExecution, Depend
ensureDependenciesAreResolved(mojoDescriptor, session, dependencyContext);
- try (NoExceptionCloseable lock = getProjectLock(session, mojoDescriptor)) {
+ try (NoExceptionCloseable ignore = getProjectLock(session, mojoDescriptor)) {
Review Comment:
This code makes no sense then. Why declare a field not used?
Then simply remove the overhead not needed:
<img width="1148" alt="image" src="https://github.com/user-attachments/assets/ef738267-e474-4549-bd61-4083935146f4" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2103900101
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -50,8 +50,6 @@ public class DefaultUpdateCheckManager extends AbstractLogEnabled implements Upd
private static final String ERROR_KEY_SUFFIX = ".error";
- public DefaultUpdateCheckManager() {}
Review Comment:
yes, we apply use (test) or loose.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2103907689
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -303,7 +301,7 @@ private Properties read(File touchfile) {
Properties props = new Properties();
try (FileInputStream in = new FileInputStream(touchfile)) {
- try (FileLock lock = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
+ try (FileLock ignored = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
Review Comment:
really? check out the usage. Its **unused for sure**, or the last 15 years i have done everything wrong, not even understood basics in pointer and reference.
https://www.geeksforgeeks.org/reference-variable-in-java/
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -303,7 +301,7 @@ private Properties read(File touchfile) {
Properties props = new Properties();
try (FileInputStream in = new FileInputStream(touchfile)) {
- try (FileLock lock = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
Review Comment:
the block is super small its **defacto** unused or im not Vincent Potucek.
<img width="1137" alt="image" src="https://github.com/user-attachments/assets/130bce87-a928-4ede-bf4e-bef2e88a50c7" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2104008572
##########
compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java:
##########
@@ -303,7 +301,7 @@ private Properties read(File touchfile) {
Properties props = new Properties();
try (FileInputStream in = new FileInputStream(touchfile)) {
- try (FileLock lock = in.getChannel().lock(0, Long.MAX_VALUE, true)) {
Review Comment:
its is an error indication, therefore should be named according to convention.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: `DefaultUpdateCheckManager` Fix variable 'lock' is never used (PMD: UnusedPrivateField) [maven]
Posted by "Pankraz76 (via GitHub)" <gi...@apache.org>.
Pankraz76 commented on code in PR #2376:
URL: https://github.com/apache/maven/pull/2376#discussion_r2103910930
##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java:
##########
@@ -306,7 +306,7 @@ private void doExecute(MavenSession session, MojoExecution mojoExecution, Depend
ensureDependenciesAreResolved(mojoDescriptor, session, dependencyContext);
- try (NoExceptionCloseable lock = getProjectLock(session, mojoDescriptor)) {
+ try (NoExceptionCloseable ignore = getProjectLock(session, mojoDescriptor)) {
Review Comment:
really? Is your IDE showing something different?
Looks like a bug in maven to me.
<img width="1331" alt="image" src="https://github.com/user-attachments/assets/d5fc78b9-51e8-435b-97b1-b7724b2ccd62" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org