Re: [PR] remove usage of IOUtil.close [netbeans-mavenutils-nbm-maven-plugin]

2024-02-21 Thread via GitHub


ebarboni merged PR #149:
URL: https://github.com/apache/netbeans-mavenutils-nbm-maven-plugin/pull/149


-- 
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: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Re: [PR] remove usage of IOUtil.close [netbeans-mavenutils-nbm-maven-plugin]

2024-02-21 Thread via GitHub


ebarboni commented on PR #149:
URL: 
https://github.com/apache/netbeans-mavenutils-nbm-maven-plugin/pull/149#issuecomment-1956331696

   Yep but changing for new code will make the source a patchwork


-- 
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: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Re: [PR] remove usage of IOUtil.close [netbeans-mavenutils-nbm-maven-plugin]

2024-02-21 Thread via GitHub


mbien commented on PR #149:
URL: 
https://github.com/apache/netbeans-mavenutils-nbm-maven-plugin/pull/149#issuecomment-1956257424

   NB can format code sections. You select something and format.


-- 
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: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Re: [PR] remove usage of IOUtil.close [netbeans-mavenutils-nbm-maven-plugin]

2024-02-21 Thread via GitHub


ebarboni commented on PR #149:
URL: 
https://github.com/apache/netbeans-mavenutils-nbm-maven-plugin/pull/149#issuecomment-1956250520

   I will do on two line. I think I will have nervous breakdown and autoformat 
all and do a no op push to have in native NetBeans format like nb-pakage.


-- 
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: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Re: [PR] remove usage of IOUtil.close [netbeans-mavenutils-nbm-maven-plugin]

2024-02-21 Thread via GitHub


mbien commented on code in PR #149:
URL: 
https://github.com/apache/netbeans-mavenutils-nbm-maven-plugin/pull/149#discussion_r1497167259


##
nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/CreateWebstartAppMojo.java:
##
@@ -616,66 +616,44 @@ private File copyLauncher( File standaloneBuildDir, File 
builtInstallation )
 File jnlpStarter
 = new File( builtInstallation.getAbsolutePath() + 
File.separator + "harness" + File.separator + "jnlp"
 + File.separator + "jnlp-launcher.jar" );
-// buffer so it isn't reading a byte at a time!
-InputStream source = null;
-FileOutputStream outstream = null;
-try
-{
-if ( !jnlpStarter.exists() )
-{
-source = getClass().getClassLoader().getResourceAsStream(
-"harness/jnlp/jnlp-launcher.jar" );
-}
-else
-{
-source = new FileInputStream( jnlpStarter );
-}
-File jnlpDestination = new File(
+// buffer so it isn't reading a byte at a time!  
+File jnlpDestination = new File(
 standaloneBuildDir.getAbsolutePath() + File.separator + 
"jnlp-launcher.jar" );
-
-outstream = new FileOutputStream( jnlpDestination );
+try ( InputStream source = ( !jnlpStarter.exists() ? 
+ 
getClass().getClassLoader().getResourceAsStream("harness/jnlp/jnlp-launcher.jar"
 ) : 
+ new FileInputStream( jnlpStarter )) ;
+  FileOutputStream outstream = new FileOutputStream( 
jnlpDestination ); )
+{
 IOUtil.copy( source, outstream );
 return jnlpDestination;
-}
-finally
-{
-IOUtil.close( source );
-IOUtil.close( outstream );
-}
+}
 }
 
 private void filterCopy( File sourceFile, String resourcePath, File 
destinationFile, Properties filterProperties )
 throws IOException
 {
 // buffer so it isn't reading a byte at a time!
-Reader source = null;
-Writer destination = null;
-try
+
+InputStream instream;
+if ( sourceFile != null )
+{
+instream = new FileInputStream( sourceFile );
+}
+else
+{
+instream = getClass().getClassLoader().getResourceAsStream( 
resourcePath );
+}
+
+FileOutputStream outstream = new FileOutputStream( destinationFile ); 
+
+try ( Reader source = new BufferedReader( new InputStreamReader( 
instream, "UTF-8" ) ); Writer destination = new OutputStreamWriter( outstream, 
"UTF-8" ); )
 {

Review Comment:
   ```java
   try (Reader source = new BufferedReader(new 
InputStreamReader(instream, "UTF-8")); 
Writer destination = new OutputStreamWriter(outstream, 
"UTF-8"))  {
   ```



-- 
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: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Re: [PR] remove usage of IOUtil.close [netbeans-mavenutils-nbm-maven-plugin]

2024-02-21 Thread via GitHub


mbien commented on code in PR #149:
URL: 
https://github.com/apache/netbeans-mavenutils-nbm-maven-plugin/pull/149#discussion_r1497164003


##
nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/CreateClusterAppMojo.java:
##
@@ -925,24 +913,15 @@ else if ( !name.contains( "." ) || name.endsWith( ".sh" ) 
)
 private void writeFile( String path, File destSh )
 throws IOException
 {
-InputStream instream = null;
-OutputStream output = null;
-try
+try (InputStream instream = 
getClass().getClassLoader().getResourceAsStream( path ); OutputStream output = 
new BufferedOutputStream( new FileOutputStream( destSh ) ))

Review Comment:
   split in two lines maybe?
   
   ```java
  try (InputStream instream = 
getClass().getClassLoader().getResourceAsStream(path);
   OutputStream output = new BufferedOutputStream(new 
FileOutputStream(destSh))) {
   ```



-- 
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: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Re: [PR] remove usage of IOUtil.close [netbeans-mavenutils-nbm-maven-plugin]

2024-02-21 Thread via GitHub


mbien commented on code in PR #149:
URL: 
https://github.com/apache/netbeans-mavenutils-nbm-maven-plugin/pull/149#discussion_r1497164003


##
nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/CreateClusterAppMojo.java:
##
@@ -925,24 +913,15 @@ else if ( !name.contains( "." ) || name.endsWith( ".sh" ) 
)
 private void writeFile( String path, File destSh )
 throws IOException
 {
-InputStream instream = null;
-OutputStream output = null;
-try
+try (InputStream instream = 
getClass().getClassLoader().getResourceAsStream( path ); OutputStream output = 
new BufferedOutputStream( new FileOutputStream( destSh ) ))

Review Comment:
   split in two lines maybe?
   
   ```java
  try (InputStream instream = 
getClass().getClassLoader().getResourceAsStream(path);
 OutputStream output = new BufferedOutputStream(new 
FileOutputStream(destSh))) {
   ```



##
nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/CreateClusterAppMojo.java:
##
@@ -925,24 +913,15 @@ else if ( !name.contains( "." ) || name.endsWith( ".sh" ) 
)
 private void writeFile( String path, File destSh )
 throws IOException
 {
-InputStream instream = null;
-OutputStream output = null;
-try
+try (InputStream instream = 
getClass().getClassLoader().getResourceAsStream( path ); OutputStream output = 
new BufferedOutputStream( new FileOutputStream( destSh ) ))

Review Comment:
   split in two lines maybe?
   
   ```java
  try (InputStream instream = 
getClass().getClassLoader().getResourceAsStream(path);
  OutputStream output = new BufferedOutputStream(new 
FileOutputStream(destSh))) {
   ```



-- 
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: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists