New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes issue 24868 Clean code: fix unlikely argument and remove some unused variables. #24870
Conversation
unused variables. ManagedBeanManagerImpl and JdbcConnPoolAppStatsProvider need specific review.
unused variables. ManagedBeanManagerImpl and JdbcConnPoolAppStatsProvider need specific review. (Remove unused imports)
I will have a look at the
build failure. Note to myself: mvn checkstyle:check -Pqa for a quick test if build mvn clean install -Pfastest -T4C succeeded. |
unused variables. ManagedBeanManagerImpl and JdbcConnPoolAppStatsProvider need specific review. (Fix checkstyle 'Line has trailing spaces')
I probably made something in 'appserv-tests'
fail. I will look into it. |
Build server tests now succeed (thank you for starting a new build manually, was the cause the "java.net.BindException: Address already in use"?) And I also ran the ant tests locally and they succeed:
|
Commit comment and PR title suggest that this fixes some issue. GH provides https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue - with specific syntax for that to happen automatically. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, except that ordering of imports, but as we still don't have checkstyle rule enabled for that I can accept that even as it is.
@@ -335,7 +335,7 @@ public void unloadManagedBeans(Application app) { | |||
+ " with jndi name " + jndiName, ne); | |||
} | |||
} else { | |||
appClientManagedBeans.remove(jndiName); | |||
appClientManagedBeans.remove(jndiName.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, good catch!
@@ -43,7 +35,13 @@ | |||
import org.jvnet.hk2.config.TransactionFailure; | |||
import org.jvnet.hk2.config.types.Property; | |||
|
|||
import static com.sun.appserv.connectors.internal.api.ConnectorsUtil.deriveResourceName; | |||
import com.sun.appserv.connectors.internal.api.ConnectorConstants; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imports should be ordered by alphabet. Static imports should be first or last, but together, that is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I assumed the ee4j Eclipse formatter took care of the order. I will minimise import statement changes in the future.
try { | ||
ic = (new FileInputStream(fileSrc)).getChannel(); | ||
oc = (new FileOutputStream(fileDest)).getChannel(); | ||
try (FileChannel ic = (new FileInputStream(fileSrc)).getChannel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure now, is closing the channel enough to close the input stream? Is it possible that GC would close the input stream before the channel (no reference to the IS)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure. I did compare it to the latest real catalina Expandwar code. They used the same approach, so I assumed it was safe. Note that latest ExpandWar in catalina has some other fixes that are not in this fork.
https://github.com/apache/tomcat/blob/main/java/org/apache/catalina/startup/ExpandWar.java
Is it possible you introduced a new error somehow - sometimes Jenkins fails this test on JDK21, that did not happen before:
It is quite often but not well reproducible, seems like some race condition. Could be caused also by some other change, but this is the closest one. |
I added the test about a month ago, the test might also be incorrect / my reading / understanding of the code might be incorrect. If it is needed line ConnectionPoolTest.java:314 could be disabled / removed. Looking at the test itself, I do not think I can prove with the current test code that the maximum of 5 connections in the pool is really reached. Perhaps Jdk21 is quicker with each thread (due to virtual threads enhancements?, although the test is not using virtual threads) which prevents the maximum of the connection pool to be used, and only 3 of 5 are used. Starting 100 tasks with 30 threads in parallel while each one sleeps for sleep(0, 10) nanos as work might not be enough to fill up 5 resources from the pool. |
Installed OpenJDK21U-jdk_x64_windows_hotspot_21.0.3_9.zip in windows. Ran 20 times "mvn test -offline" in module "connectors-runtime", ConnectionPoolTest never failed. I think the test with line 314 is 'CPU / machine' dependent (I use a 6 year old i7 8700 cpu). Fixes I can think of:
I would opt for option 1 or 3 to keep it simple, the test is already complicated enough. |
Created issue #24931 to improve the test, creating a pull request. |
ManagedBeanManagerImpl and JdbcConnPoolAppStatsProvider need specific review.
I did not add a nullcheck for SimpleJndiName in JdbcConnPoolAppStatsProvider, since the constructor already validates it.
Full list of items is listed in issue #24868