notzed commented on issue #4141:
URL: https://github.com/apache/netbeans/issues/4141#issuecomment-1140562254

   So as above i've created a patch for this.  It's not a particularly large 
patch because it's a small file but it does change almost all the logic.  I'm 
sorry I don't really know how github works as i prefer just mailing diffs 
around so i'm not sure what's next.  I also apologise that I messed up the 
username in the commit and can't seem to change it in-place, but i suppose i 
can create another branch before submitting a pull request to fix that.  Is 
this the place to discuss or should i subscribe to the dev list?
   
   The primary changes are using matches() rather than find() in the regex and 
using a buffer to stream.read().  The former has identical behaviour since the 
regex has a greedy match at both ends.  For the latter I believe the semantics 
should be the same (i.e. non-delayed reading) as InputStream.read() is 
documented to return when some data is ready and doesn't wait to fill the 
buffer.
   
   There were also some serious logic problems with the existing code which has 
clearly been patched multiple times with 'hot fixes' which only hid any 
problems and also made the code worse. e.g. 
https://bz.apache.org/netbeans/show_bug.cgi?id=200365
   
   There are several but one example 'logLevel' is passed around as an Integer 
and used as nullable flag to determine whether to use the 'outputstream' or the 
'NbBuildLogger' variables for the output - however set*Stream() calls can set 
the logLevel when using a delegate stream or if os is null ... but that stream 
is never even used because logLevel gets set to non-null.  In fact the 
nbbuildlogger might not be present (hence the null checks for ow, etc).  There 
were also multiple places this stuff is checked and re-checked.  I've removed 
all that and replaced it with separate classes for each case to that both can 
work with guaranteed invariants and this greatly simplifies the logic and 
readability.
   
   Other smaller changes include using an ExecutorService to create and manage 
the threads, isolating the critical sections to small functions, removing 
ThreadDeath exception handling (only for Thread.close() which is never called), 
and removing things like flushing the output from the stop() function since 
this is always called in the finally block and so on.  And finally just 
rearranging the if() test for calling findHyperLinks to be clearer (that was 
hellishly confusing for such a simple check).
   
   I'm sorry I don't really use ant other than for the default netbeans and 
build.xml for modular projects (i use GNU Make for anything more complicated) 
so i'm not sure how to test it to the level such a set of changes require.
   


-- 
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

Reply via email to