mbien commented on code in PR #8228:
URL: https://github.com/apache/netbeans/pull/8228#discussion_r2157967270
##########
enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ear/EarImpl.java:
##########
@@ -257,15 +270,22 @@ public J2eeModule.Type getModuleType() {
*/
@Override
public String getModuleVersion() {
- Profile prf = getJ2eeProfile();
- if (prf == Profile.JAKARTA_EE_11_FULL || prf ==
Profile.JAKARTA_EE_11_FULL) return Application.VERSION_11;
- if (prf == Profile.JAKARTA_EE_10_FULL || prf ==
Profile.JAKARTA_EE_10_FULL) return Application.VERSION_10;
- if (prf == Profile.JAKARTA_EE_9_1_FULL || prf ==
Profile.JAKARTA_EE_9_FULL) return Application.VERSION_9;
- if (prf == Profile.JAKARTA_EE_8_FULL || prf == Profile.JAVA_EE_8_FULL)
return Application.VERSION_8;
- if (prf == Profile.JAVA_EE_7_FULL) return Application.VERSION_7;
- if (prf == Profile.JAVA_EE_6_FULL) return Application.VERSION_6;
- if (prf == Profile.JAVA_EE_5) return Application.VERSION_5;
- return Application.VERSION_1_4;
+ Profile profile = getJ2eeProfile();
+ if (null == profile) {
+ return Application.VERSION_8;
+ }
+ else {
Review Comment:
nitpick: `} else {`
##########
enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ear/EarImpl.java:
##########
@@ -724,10 +743,10 @@ private EarImpl.MavenModule[] readPomModules() {
}
private MavenModule[] checkConfiguration(MavenProject prj, Object conf) {
- List<MavenModule> toRet = new ArrayList<MavenModule>();
- if (conf instanceof Xpp3Dom) {
+ List<MavenModule> toRet = new ArrayList<>();
+ if (conf instanceof Xpp3Dom xpp3Dom) {
ExpressionEvaluator eval =
PluginPropertyUtils.createEvaluator(project);
- Xpp3Dom dom = (Xpp3Dom) conf;
+ Xpp3Dom dom = xpp3Dom;
Xpp3Dom modules = dom.getChild("modules"); //NOI18N
Review Comment:
suggestion: replace `xpp3Dom` with `dom`,
this would allow to remove the redundant `Xpp3Dom dom = xpp3Dom;` variable.
##########
enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ear/EarImpl.java:
##########
@@ -905,12 +919,26 @@ public void
removePropertyChangeListener(PropertyChangeListener listener) {
@Override
public boolean equals(Object obj) {
- return module.equals(obj);
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final ProxyJ2eeModule other = (ProxyJ2eeModule) obj;
+ return Objects.equals(this.module, other.module);
}
@Override
public int hashCode() {
- return module.hashCode();
+ int hash = 5;
+ hash = 31 * hash + Objects.hashCode(this.module);
+ hash = 31 * hash + Objects.hashCode(this.mavenModule);
+ hash = 31 * hash + Objects.hashCode(this.fileNameMapping);
+ return hash;
}
Review Comment:
`equals` and `hashCode` should cover the same fields, otherwise the ["equal
objects must have equal hash
code"](https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object))
rule is broken.
##########
enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/WSUtils.java:
##########
@@ -137,24 +141,10 @@ public static void generateSunJaxwsFile(final FileObject
targetDir) throws IOExc
@Override
public void run() throws IOException {
FileObject sunJaxwsFo = FileUtil.createData(targetDir,
"sun-jaxws.xml");//NOI18N
- FileLock lock = sunJaxwsFo.lock();
- BufferedWriter bw = null;
- OutputStream os = null;
- OutputStreamWriter osw = null;
- try {
- os = sunJaxwsFo.getOutputStream(lock);
- osw = new OutputStreamWriter(os, StandardCharsets.UTF_8);
- bw = new BufferedWriter(osw);
+ try (FileLock lock = sunJaxwsFo.lock(); OutputStream os =
sunJaxwsFo.getOutputStream(lock);
+ OutputStreamWriter osw = new OutputStreamWriter(os,
StandardCharsets.UTF_8);
+ BufferedWriter bw = new BufferedWriter(osw)) {
bw.write(sunJaxwsContent);
- } finally {
Review Comment:
suggestion:
```java
try (FileLock lock = sunJaxwsFo.lock();
BufferedWriter bw = new BufferedWriter(
new
OutputStreamWriter(sunJaxwsFo.getOutputStream(lock), StandardCharsets.UTF_8))) {
```
`bw` will close all wrapped streams.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists