This is an automated email from the ASF dual-hosted git repository. juanpablo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jspwiki.git
commit db3f7f158d47aace27eae819a027a705c483988f Author: juanpablo <juanpa...@apache.org> AuthorDate: Sun Nov 4 01:30:04 2018 +0100 avoid concurrency issue by building a new Set, remove close it's called implicitly --- .../java/org/apache/wiki/ReferenceManager.java | 24 ++++++---------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java index eebfa08..097335b 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java @@ -482,10 +482,8 @@ public class ReferenceManager // f = new File( f, hashName ); - try( ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream(new FileOutputStream(f)) ) ) - { - // FIXME: There is a concurrency issue here... - Set< Map.Entry < String, Object > > entries = p.getAttributes().entrySet(); + try( ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream( new FileOutputStream( f ) ) ) ) { + Set< Map.Entry < String, Object > > entries = new HashSet<>( p.getAttributes().entrySet() ); // new Set to avoid concurrency issue if( entries.size() == 0 ) { @@ -502,29 +500,19 @@ public class ReferenceManager out.writeUTF( p.getName() ); out.writeLong( entries.size() ); - for( Iterator< Map.Entry < String, Object > > i = entries.iterator(); i.hasNext(); ) - { + for( Iterator< Map.Entry < String, Object > > i = entries.iterator(); i.hasNext(); ) { Map.Entry< String, Object > e = i.next(); - if( e.getValue() instanceof Serializable ) - { + if( e.getValue() instanceof Serializable ) { out.writeUTF( e.getKey() ); out.writeObject( e.getValue() ); } } - out.close(); - - } - catch( IOException e ) - { + } catch( IOException e ) { log.error( "Unable to serialize!", e ); - - } - finally - { + } finally { sw.stop(); - log.debug("serialization for "+p.getName()+" done - took "+sw); } }