You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2020/10/14 17:54:22 UTC

[jspwiki] branch master updated (43a15c8 -> 1042544)

This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git.


    from 43a15c8  fix tests' flakiness
     new 82877f4  DefaultWorkflowManager stores only last jspwiki.workflow.completed.retain (defaulting to 2048) completed workflows
     new 0a61e38  apply format
     new 50f3761  JSPWIKI-1114: Preview parameter cutting now only at newlines, patch suggested by Ulf Dittmer - thanks!
     new 1caf85a  LuceneSearchProvider using now NIOFSDirectory instead of (deprecated) SimpleFSDirectory
     new 8e23433  CircularFifoQueue used in DefaultWorkflowManager comes from commons-collections4
     new 1042544  2.11.0-M8-git-02

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ChangeLog.md                                       | 10 +++++++-
 .../src/main/java/org/apache/wiki/api/Release.java |  2 +-
 jspwiki-main/pom.xml                               |  5 ++++
 .../java/org/apache/wiki/plugin/WeblogPlugin.java  |  9 ++-----
 .../apache/wiki/search/LuceneSearchProvider.java   | 30 ++++++++--------------
 .../apache/wiki/tasks/pages/SaveWikiPageTask.java  |  2 +-
 .../wiki/workflow/DefaultWorkflowManager.java      | 13 +++++++---
 pom.xml                                            |  7 +++++
 8 files changed, 45 insertions(+), 33 deletions(-)


[jspwiki] 05/06: CircularFifoQueue used in DefaultWorkflowManager comes from commons-collections4

Posted by ju...@apache.org.
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 8e23433689f943ac38efb981e33b8b7eef355096
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Oct 14 19:52:42 2020 +0200

    CircularFifoQueue used in DefaultWorkflowManager comes from commons-collections4
---
 jspwiki-main/pom.xml | 5 +++++
 pom.xml              | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/jspwiki-main/pom.xml b/jspwiki-main/pom.xml
index a2ebf45..4a9752a 100644
--- a/jspwiki-main/pom.xml
+++ b/jspwiki-main/pom.xml
@@ -54,6 +54,11 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-collections4</artifactId>
+    </dependency>
+
+    <dependency>
       <groupId>org.apache.lucene</groupId>
       <artifactId>lucene-queryparser</artifactId>
     </dependency>
diff --git a/pom.xml b/pom.xml
index 0f6effb..685a980 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,6 +46,7 @@
 
     <akismet-java.version>1.02</akismet-java.version>
     <awaitility.version>4.0.3</awaitility.version>
+    <commons-collections.version>4.4</commons-collections.version>
     <commons-fileupload.version>1.4</commons-fileupload.version>
     <commons-httpclient.version>3.1</commons-httpclient.version>
     <commons-io.version>2.8.0</commons-io.version>
@@ -188,6 +189,12 @@
 
       <dependency>
         <groupId>org.apache.commons</groupId>
+        <artifactId>commons-collections4</artifactId>
+        <version>${commons-collections.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.commons</groupId>
         <artifactId>commons-lang3</artifactId>
         <version>${commons-lang.version}</version>
       </dependency>


[jspwiki] 02/06: apply format

Posted by ju...@apache.org.
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 0a61e38e593852c9b6bf4a3918c2f5b1a18057ca
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Oct 14 19:44:27 2020 +0200

    apply format
---
 .../src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java b/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java
index 4ef9f23..ffa7947 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java
@@ -64,7 +64,7 @@ public class SaveWikiPageTask extends Task {
         context.getEngine().getManager( FilterManager.class ).doPostSaveFiltering( context, proposedText );
 
         // Reindex saved page
-        context.getEngine().getManager(SearchManager.class ).reindexPage( page );
+        context.getEngine().getManager( SearchManager.class ).reindexPage( page );
 
         return Outcome.STEP_COMPLETE;
     }


[jspwiki] 03/06: JSPWIKI-1114: Preview parameter cutting now only at newlines, patch suggested by Ulf Dittmer - thanks!

Posted by ju...@apache.org.
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 50f376122bf3265e99c9f5d1629c34c035871825
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Oct 14 19:45:16 2020 +0200

    JSPWIKI-1114: Preview parameter cutting now only at newlines, patch suggested by Ulf Dittmer - thanks!
---
 .../src/main/java/org/apache/wiki/plugin/WeblogPlugin.java       | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
index 397e6ce..148b4f8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
@@ -311,7 +311,7 @@ public class WeblogPlugin implements Plugin, ParserStagePlugin {
         if (preview > 0) {
             //
             // We start with the first 'preview' number of characters from the text,
-            // and then add characters to it until we get to a linebreak or a period.
+            // and then add characters to it until we get to a linebreak.
             // The idea is that cutting off at a linebreak is less likely
             // to disturb the HTML and leave us with garbled output.
             //
@@ -321,11 +321,6 @@ public class WeblogPlugin implements Plugin, ParserStagePlugin {
                 if (html.charAt(cutoff) == '\r' || html.charAt(cutoff) == '\n') {
                     hasBeenCutOff = true;
                     break;
-                } else if (html.charAt(cutoff) == '.') {
-                    // we do want the period
-                    cutoff++;
-                    hasBeenCutOff = true;
-                    break;
                 }
                 cutoff++;
             }
@@ -353,7 +348,7 @@ public class WeblogPlugin implements Plugin, ParserStagePlugin {
             author = "AnonymousCoward";
         }
 
-        buffer.append( MessageFormat.format( rb.getString("weblogentryplugin.postedby"), author));
+        buffer.append( MessageFormat.format( rb.getString( "weblogentryplugin.postedby" ), author ) );
         buffer.append( "<a href=\"" + entryCtx.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), entry.getName() ) + "\">" + rb.getString("weblogentryplugin.permalink") + "</a>" );
         final String commentPageName = TextUtil.replaceString( entry.getName(), "blogentry", "comments" );
 


[jspwiki] 06/06: 2.11.0-M8-git-02

Posted by ju...@apache.org.
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 1042544144954d9895ae8d2d2c49c0ca52ed47e7
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Oct 14 19:53:42 2020 +0200

    2.11.0-M8-git-02
---
 ChangeLog.md                                               | 10 +++++++++-
 jspwiki-api/src/main/java/org/apache/wiki/api/Release.java |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index 6f844ac..aebc593 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -17,7 +17,15 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-**2020-09-30  Juan Pablo Santos (juanpablo AT apache DOT org)**
+**2020-10-14  Juan Pablo Santos (juanpablo AT apache DOT org)**
+
+* _2.11.0-M8-git-02_
+
+* [JSPWIKI-1114](https://issues.apache.org/jira/browse/JSPWIKI-1131): Show only part of Weblog entry on the overview page.
+    * Preview parameter cutting now only at newlines, patch suggested by Ulf Dittmer - thanks!
+
+* LuceneSearchProvider using now NIOFSDirectory instead of (deprecated) SimpleFSDirectory. Also, all Lucene's index
+  writes are synchronized, whereas reads are not. This should help with issues noted at [JSPWIKI-1131](https://issues.apache.org/jira/browse/JSPWIKI-1131).
 
 * _2.11.0-M8-git-01_
 
diff --git a/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java b/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java
index 07c986c..7bf8e73 100644
--- a/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java
+++ b/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java
@@ -69,7 +69,7 @@ public final class Release {
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "git-01";
+    public static final String     BUILD         = "git-02";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of


[jspwiki] 04/06: LuceneSearchProvider using now NIOFSDirectory instead of (deprecated) SimpleFSDirectory

Posted by ju...@apache.org.
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 1caf85ac50871b0eef48556b148702d7e5ec4e04
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Oct 14 19:46:46 2020 +0200

    LuceneSearchProvider using now NIOFSDirectory instead of (deprecated) SimpleFSDirectory
    
    Also, all Lucene's index writes are synchronized, whereas reads are not. This should help with issues noted at JSPWIKI-1131
---
 .../apache/wiki/search/LuceneSearchProvider.java   | 30 ++++++++--------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
index 8d8bd0e..812186a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
@@ -45,7 +45,7 @@ import org.apache.lucene.search.highlight.QueryScorer;
 import org.apache.lucene.search.highlight.SimpleHTMLEncoder;
 import org.apache.lucene.search.highlight.SimpleHTMLFormatter;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.SimpleFSDirectory;
+import org.apache.lucene.store.NIOFSDirectory;
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WatchDog;
 import org.apache.wiki.WikiBackgroundThread;
@@ -67,19 +67,9 @@ import org.apache.wiki.util.ClassUtil;
 import org.apache.wiki.util.FileUtil;
 import org.apache.wiki.util.TextUtil;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.io.StringWriter;
+import java.io.*;
 import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
+import java.util.*;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
 
@@ -205,7 +195,7 @@ public class LuceneSearchProvider implements SearchProvider {
 
                 log.info("Starting Lucene reindexing, this can take a couple of minutes...");
 
-                final Directory luceneDir = new SimpleFSDirectory( dir.toPath() );
+                final Directory luceneDir = new NIOFSDirectory( dir.toPath() );
                 try( final IndexWriter writer = getIndexWriter( luceneDir ) ) {
                     final Collection< Page > allPages = m_engine.getManager( PageManager.class ).getAllPages();
                     for( final Page page : allPages ) {
@@ -312,7 +302,7 @@ public class LuceneSearchProvider implements SearchProvider {
         pageRemoved( page );
 
         // Now add back the new version.
-        try( final Directory luceneDir = new SimpleFSDirectory( new File( m_luceneDirectory ).toPath() );
+        try( final Directory luceneDir = new NIOFSDirectory( new File( m_luceneDirectory ).toPath() );
              final IndexWriter writer = getIndexWriter( luceneDir ) ) {
             luceneIndexPage( page, text, writer );
         } catch( final IOException e ) {
@@ -400,7 +390,9 @@ public class LuceneSearchProvider implements SearchProvider {
             field = new Field( LUCENE_PAGE_KEYWORDS, page.getAttribute( "keywords" ).toString(), TextField.TYPE_STORED );
             doc.add( field );
         }
-        writer.addDocument(doc);
+        synchronized( writer ) {
+            writer.addDocument(doc);
+        }
 
         return doc;
     }
@@ -409,8 +401,8 @@ public class LuceneSearchProvider implements SearchProvider {
      *  {@inheritDoc}
      */
     @Override
-    public void pageRemoved( final Page page ) {
-        try( final Directory luceneDir = new SimpleFSDirectory( new File( m_luceneDirectory ).toPath() );
+    public synchronized void pageRemoved( final Page page ) {
+        try( final Directory luceneDir = new NIOFSDirectory( new File( m_luceneDirectory ).toPath() );
              final IndexWriter writer = getIndexWriter( luceneDir ) ) {
             final Query query = new TermQuery( new Term( LUCENE_ID, page.getName() ) );
             writer.deleteDocuments( query );
@@ -479,7 +471,7 @@ public class LuceneSearchProvider implements SearchProvider {
         ArrayList<SearchResult> list = null;
         Highlighter highlighter = null;
 
-        try( final Directory luceneDir = new SimpleFSDirectory( new File( m_luceneDirectory ).toPath() );
+        try( final Directory luceneDir = new NIOFSDirectory( new File( m_luceneDirectory ).toPath() );
              final IndexReader reader = DirectoryReader.open( luceneDir ) ) {
             final String[] queryfields = { LUCENE_PAGE_CONTENTS, LUCENE_PAGE_NAME, LUCENE_AUTHOR, LUCENE_ATTACHMENTS, LUCENE_PAGE_KEYWORDS };
             final QueryParser qp = new MultiFieldQueryParser( queryfields, getLuceneAnalyzer() );


[jspwiki] 01/06: DefaultWorkflowManager stores only last jspwiki.workflow.completed.retain (defaulting to 2048) completed workflows

Posted by ju...@apache.org.
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 82877f4cf46f25e3ddf4e5975e451aabf57299e7
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Oct 14 19:43:59 2020 +0200

    DefaultWorkflowManager stores only last jspwiki.workflow.completed.retain (defaulting to 2048) completed workflows
    
    in order to prevent a memory hog
---
 .../org/apache/wiki/workflow/DefaultWorkflowManager.java    | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
index 433955a..81d10dc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
@@ -18,6 +18,7 @@
  */
 package org.apache.wiki.workflow;
 
+import org.apache.commons.collections4.queue.CircularFifoQueue;
 import org.apache.commons.lang3.time.StopWatch;
 import org.apache.log4j.Logger;
 import org.apache.wiki.api.core.Context;
@@ -29,6 +30,7 @@ import org.apache.wiki.auth.acl.UnresolvedPrincipal;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventEmitter;
 import org.apache.wiki.event.WorkflowEvent;
+import org.apache.wiki.util.TextUtil;
 
 import java.io.*;
 import java.security.Principal;
@@ -54,8 +56,9 @@ public class DefaultWorkflowManager implements WorkflowManager {
     DecisionQueue m_queue = new DecisionQueue();
     Set< Workflow > m_workflows;
     final Map< String, Principal > m_approvers;
-    List< Workflow > m_completed;
+    Queue< Workflow > m_completed;
     private Engine m_engine = null;
+    private int retainCompleted;
 
     /**
      * Constructs a new WorkflowManager, with an empty workflow cache.
@@ -63,7 +66,6 @@ public class DefaultWorkflowManager implements WorkflowManager {
     public DefaultWorkflowManager() {
         m_workflows = ConcurrentHashMap.newKeySet();
         m_approvers = new ConcurrentHashMap<>();
-        m_completed = new CopyOnWriteArrayList<>();
         WikiEventEmitter.attach( this );
     }
 
@@ -97,6 +99,8 @@ public class DefaultWorkflowManager implements WorkflowManager {
     @Override
     public void initialize( final Engine engine, final Properties props ) {
         m_engine = engine;
+        retainCompleted = TextUtil.getIntegerProperty( engine.getWikiProperties(), "jspwiki.workflow.completed.retain", 2048 );
+        m_completed = new CircularFifoQueue<>( retainCompleted );
 
         // Identify the workflows requiring approvals
         for( final Object o : props.keySet() ) {
@@ -135,11 +139,12 @@ public class DefaultWorkflowManager implements WorkflowManager {
                 saved        = in.readLong();
                 m_workflows  = ( Set< Workflow > )in.readObject();
                 m_queue      = ( DecisionQueue )in.readObject();
-                m_completed  = ( List< Workflow > )in.readObject();
+                m_completed = new CircularFifoQueue<>( retainCompleted );
+                m_completed.addAll( ( Collection< Workflow > )in.readObject() );
                 LOG.debug( "Read serialized data successfully in " + sw );
             }
         } catch( final IOException | ClassNotFoundException e ) {
-            LOG.error( "unable to recover from disk workflows and decision queue: " + e.getMessage(), e );
+            LOG.warn( "unable to recover from disk workflows and decision queue: " + e.getMessage() );
         }
         sw.stop();