jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1163600 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel: CommitMessage.java SubscriptionImpl.java
Date Wed, 31 Aug 2011 12:15:54 GMT
Author: mduerig
Date: Wed Aug 31 12:15:54 2011
New Revision: 1163600

URL: http://svn.apache.org/viewvc?rev=1163600&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
guard against alien commits

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/CommitMessage.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/CommitMessage.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/CommitMessage.java?rev=1163600&r1=1163599&r2=1163600&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/CommitMessage.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/CommitMessage.java
Wed Aug 31 12:15:54 2011
@@ -10,6 +10,10 @@ public class CommitMessage {
     private static final char SEPARATOR_CHAR = ':';
 
     public static CommitMessage parse(String s) {
+        if (s == null) {
+            throw new IllegalArgumentException("null");
+        }
+
         int k = s.indexOf(SEPARATOR_CHAR);
         while (k > 0 && s.charAt(k - 1) == ESCAPE_CHAR) {
             k = s.indexOf(SEPARATOR_CHAR, k + 1);

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java?rev=1163600&r1=1163599&r2=1163600&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
Wed Aug 31 12:15:54 2011
@@ -291,11 +291,11 @@ public class SubscriptionImpl implements
         private EventBundle createEventBundle(JSONObject jsonObject) throws RepositoryException
{
             String revisionId = getString(jsonObject, "id", false);
             String msg = getString(jsonObject, "msg", true);
-            if (msg == null) {
+            CommitMessage commitMessage = parseCommitMessage(msg);
+            if (commitMessage == null) {
                 // Skip alien commits
                 return null;
             }
-            CommitMessage commitMessage = CommitMessage.parse(msg);
             long timeStamp = getLong(jsonObject, "ts");
             String changes = getString(jsonObject, "changes", false);
             log.debug("Creating event bundle from changes in revision " + revisionId + "
at " + timeStamp);
@@ -324,6 +324,15 @@ public class SubscriptionImpl implements
             return new EventBundleImpl(events, isLocal);
         }
 
+        private CommitMessage parseCommitMessage(String msg) {
+            try {
+                return CommitMessage.parse(msg);
+            }
+            catch (IllegalArgumentException e) {
+                return null;
+            }
+        }
+
         private Collection<Event> getEvents(String changes, EventTemplate eventTemplate)
throws RepositoryException {
             Collection<Event> events = new ArrayList<Event>();
             JsopTokenizer jsopTokenizer = new JsopTokenizer(changes);



Mime
View raw message