You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2015/11/29 15:22:46 UTC
[1/4] zest-java git commit: ZEST-128 - Trying to improve error
reporting in exceptions.
Repository: zest-java
Updated Branches:
refs/heads/develop 52d69b6e0 -> d117531c5
ZEST-128 - Trying to improve error reporting in exceptions.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/2e5671e3
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/2e5671e3
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/2e5671e3
Branch: refs/heads/develop
Commit: 2e5671e3fd7ac3d7f1b09cf940100da1166e608d
Parents: 73b7f19
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Tue Nov 17 19:20:13 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Tue Nov 17 19:20:13 2015 +0800
----------------------------------------------------------------------
.../ConcurrentEntityModificationException.java | 23 ++++++++++++++++----
.../UnitOfWorkCompletionException.java | 2 +-
.../runtime/unitofwork/UnitOfWorkInstance.java | 8 ++++---
...currentEntityStateModificationException.java | 13 +----------
.../ConcurrentModificationCheckConcern.java | 4 ----
.../ConcurrentUoWFileModificationException.java | 3 ++-
6 files changed, 28 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/2e5671e3/core/api/src/main/java/org/apache/zest/api/unitofwork/ConcurrentEntityModificationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/ConcurrentEntityModificationException.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/ConcurrentEntityModificationException.java
index e494f82..e9656a2 100644
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/ConcurrentEntityModificationException.java
+++ b/core/api/src/main/java/org/apache/zest/api/unitofwork/ConcurrentEntityModificationException.java
@@ -14,7 +14,10 @@
package org.apache.zest.api.unitofwork;
+import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.zest.api.entity.EntityComposite;
+import org.apache.zest.api.type.HasTypes;
import org.apache.zest.api.usecase.Usecase;
/**
@@ -26,17 +29,29 @@ public class ConcurrentEntityModificationException
{
private static final long serialVersionUID = 3872723845064767689L;
- private final Iterable<EntityComposite> concurrentlyModifiedEntities;
+ private final Map<EntityComposite, HasTypes> concurrentlyModifiedEntities;
- public ConcurrentEntityModificationException( Iterable<EntityComposite> concurrentlyModifiedEntities,
+ public ConcurrentEntityModificationException( Map<EntityComposite, HasTypes> concurrentlyModifiedEntities,
Usecase usecase
)
{
- super( "Entities changed concurrently, and detected in usecase '" + usecase + "'\nModified entities : " + concurrentlyModifiedEntities );
+ super( "Entities changed concurrently, and detected in usecase '" + usecase + "'\nModified entities : " + format( concurrentlyModifiedEntities ) );
this.concurrentlyModifiedEntities = concurrentlyModifiedEntities;
}
- public Iterable<EntityComposite> concurrentlyModifiedEntities()
+ private static String format( Map<EntityComposite, HasTypes> concurrentlyModifiedEntities )
+ {
+ return concurrentlyModifiedEntities.entrySet().stream()
+ .map( entry ->
+ entry.getKey()
+ + " : "
+ + entry.getValue().types().map( Class::getSimpleName )
+ .collect( Collectors.joining( "," ) )
+ )
+ .collect( Collectors.joining( "\n" ) );
+ }
+
+ public Map<EntityComposite, HasTypes> concurrentlyModifiedEntities()
{
return concurrentlyModifiedEntities;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/2e5671e3/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCompletionException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCompletionException.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCompletionException.java
index 092fc62..b867d26 100644
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCompletionException.java
+++ b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCompletionException.java
@@ -19,7 +19,7 @@ package org.apache.zest.api.unitofwork;
* fails, this exception will be thrown.
*/
public class UnitOfWorkCompletionException
- extends Exception
+ extends RuntimeException
{
private static final long serialVersionUID = 6531642131384516904L;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/2e5671e3/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
index e9ea72c..fc0810b 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Stack;
import java.util.concurrent.TimeUnit;
import org.apache.zest.api.common.MetaInfo;
@@ -32,6 +33,7 @@ import org.apache.zest.api.metrics.MetricsCounterFactory;
import org.apache.zest.api.metrics.MetricsProvider;
import org.apache.zest.api.metrics.MetricsTimer;
import org.apache.zest.api.metrics.MetricsTimerFactory;
+import org.apache.zest.api.type.HasTypes;
import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
@@ -364,14 +366,14 @@ public final class UnitOfWorkInstance
// If we cancelled due to concurrent modification, then create the proper exception for it!
ConcurrentEntityStateModificationException mee = (ConcurrentEntityStateModificationException) e;
Collection<EntityReference> modifiedEntityIdentities = mee.modifiedEntities();
- Collection<EntityComposite> modifiedEntities = new ArrayList<>();
+ Map<EntityComposite, HasTypes> modifiedEntities = new HashMap<>();
for( EntityReference modifiedEntityIdentity : modifiedEntityIdentities )
{
instanceCache.values().stream()
.filter( instance -> instance.identity().equals( modifiedEntityIdentity ) )
- .forEach( instance -> modifiedEntities.add( instance.<EntityComposite>proxy() ) );
+ .forEach( instance -> modifiedEntities.put( instance.<EntityComposite>proxy(), instance ) );
}
- throw new ConcurrentEntityModificationException( modifiedEntities, ( (ConcurrentEntityStateModificationException) e ).getUsecase() );
+ throw new ConcurrentEntityModificationException( modifiedEntities, usecase );
}
else
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/2e5671e3/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentEntityStateModificationException.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentEntityStateModificationException.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentEntityStateModificationException.java
index b6716ed..dd08ff3 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentEntityStateModificationException.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentEntityStateModificationException.java
@@ -28,7 +28,6 @@ public class ConcurrentEntityStateModificationException
extends EntityStoreException
{
private Collection<EntityReference> modifiedEntities;
- private Usecase usecase;
public ConcurrentEntityStateModificationException( Collection<EntityReference> modifiedEntities )
{
@@ -44,16 +43,6 @@ public class ConcurrentEntityStateModificationException
@Override
public String getMessage()
{
- return "Entities changed concurrently. Changes detected in usecase '" + usecase + "\nModified entities are;\n" + modifiedEntities;
- }
-
- public Usecase getUsecase()
- {
- return usecase;
- }
-
- public void setUsecase( Usecase usecase )
- {
- this.usecase = usecase;
+ return "Entities changed concurrently.\nModified entities are;\n" + modifiedEntities;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/2e5671e3/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
index 5ed5f91..9e85c83 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
@@ -131,10 +131,6 @@ public abstract class ConcurrentModificationCheckConcern
catch( EntityStoreException e )
{
lock.writeLock().unlock();
- if( e instanceof ConcurrentEntityStateModificationException )
- {
- ((ConcurrentEntityStateModificationException) e).setUsecase( usecase() );
- }
throw e;
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/2e5671e3/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/ConcurrentUoWFileModificationException.java
----------------------------------------------------------------------
diff --git a/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/ConcurrentUoWFileModificationException.java b/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/ConcurrentUoWFileModificationException.java
index c1d8fe6..d91fabf 100644
--- a/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/ConcurrentUoWFileModificationException.java
+++ b/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/ConcurrentUoWFileModificationException.java
@@ -19,6 +19,7 @@ package org.apache.zest.library.uowfile.internal;
import java.util.Collections;
import org.apache.zest.api.entity.EntityComposite;
+import org.apache.zest.api.type.HasTypes;
import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
import org.apache.zest.api.usecase.Usecase;
@@ -29,7 +30,7 @@ public class ConcurrentUoWFileModificationException
ConcurrentUoWFileModificationException( Iterable<UoWFile> concurrentlyModifiedFiles, Usecase usecase )
{
- super( Collections.<EntityComposite>emptyList(), usecase );
+ super( Collections.<EntityComposite,HasTypes>emptyMap(), usecase );
this.concurrentlyModifiedFiles = concurrentlyModifiedFiles;
}
[3/4] zest-java git commit: Merge remote-tracking branch
'origin/develop' into develop
Posted by ni...@apache.org.
Merge remote-tracking branch 'origin/develop' into develop
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/31e00415
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/31e00415
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/31e00415
Branch: refs/heads/develop
Commit: 31e004150e7da1b6c0737a862cd0b6f09f37234f
Parents: 725b616 52d69b6
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Sun Nov 29 14:04:13 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Sun Nov 29 14:04:13 2015 +0800
----------------------------------------------------------------------
.../apache/zest/api/unitofwork/UnitOfWork.java | 18 +++--
.../runtime/composite/ConstructorsModel.java | 31 +++------
.../injection/InjectedParametersModel.java | 16 -----
.../ConstructorInjectionOfThisTest.java | 72 +++++++++++++++++---
.../zest/runtime/mixin/PrivateMixinTest.java | 38 +++++++++--
.../org/apache/zest/spi/module/ModuleSpi.java | 5 --
libraries/restlet/build.gradle | 2 +-
.../zest/library/scheduler/CronSchedule.java | 3 +-
.../zest/library/scheduler/ScheduleFactory.java | 2 -
.../library/scheduler/defaults/package.html | 21 ++++++
.../library/scheduler/internal/Execution.java | 5 +-
.../scheduler/internal/ScheduleTime.java | 4 +-
.../scheduler/internal/SchedulerMixin.java | 2 +-
.../library/scheduler/internal/package.html | 21 ++++++
.../library/scheduler/CronScheduleTest.java | 19 ++----
15 files changed, 171 insertions(+), 88 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/31e00415/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
----------------------------------------------------------------------
diff --cc libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
index 08eb627,7eb53ea..1925ac6
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
@@@ -168,10 -171,10 +168,10 @@@ public interface Executio
{
submitTaskForExecution( oldScheduleTime );
Schedule schedule = uow.get( Schedule.class, oldScheduleTime.scheduleIdentity() );
- long nextTime = schedule.nextRun( now + 1000 );
+ long nextTime = schedule.nextRun( now );
if( nextTime != Long.MIN_VALUE )
{
- ScheduleTime newScheduleTime = new ScheduleTime( schedule.identity().get(), nextTime );
+ ScheduleTime newScheduleTime = new ScheduleTime( oldScheduleTime.scheduleIdentity(), nextTime );
synchronized( lock )
{
// Re-add to the Timing Queue, to re-position the sorting.
[4/4] zest-java git commit: Forgot to set SUCCESS in
ZestEntityRestlet, causing a 303... :-?
Posted by ni...@apache.org.
Forgot to set SUCCESS in ZestEntityRestlet, causing a 303... :-?
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/d117531c
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/d117531c
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/d117531c
Branch: refs/heads/develop
Commit: d117531c577d2aeafd57033fe1e24a4207ae5ba1
Parents: 31e0041
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Sun Nov 29 22:22:09 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Sun Nov 29 22:22:09 2015 +0800
----------------------------------------------------------------------
.../java/org/apache/zest/library/restlet/ZestEntityRestlet.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d117531c/libraries/restlet/src/main/java/org/apache/zest/library/restlet/ZestEntityRestlet.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/ZestEntityRestlet.java b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/ZestEntityRestlet.java
index 5ee575f..1edddb7 100644
--- a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/ZestEntityRestlet.java
+++ b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/ZestEntityRestlet.java
@@ -129,6 +129,7 @@ public class ZestEntityRestlet<T extends Identity> extends Restlet
{
put( request, response );
}
+ response.setStatus( Status.SUCCESS_OK );
}
catch( RuntimeException e )
{
[2/4] zest-java git commit: ZEST-128 - Tidying up
Posted by ni...@apache.org.
ZEST-128 - Tidying up
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/725b616f
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/725b616f
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/725b616f
Branch: refs/heads/develop
Commit: 725b616f26074625f9f4b2247d92449b2eab287f
Parents: 2e5671e
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Tue Nov 17 19:21:45 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Tue Nov 17 19:21:45 2015 +0800
----------------------------------------------------------------------
.../apache/zest/entitystore/file/FileEntityStoreMixin.java | 5 +++++
.../rest/client/ContextResourceClientFactoryTest.java | 3 ++-
.../apache/zest/library/scheduler/internal/Execution.java | 9 +++------
3 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/725b616f/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java b/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
index ce6f74f..791779e 100644
--- a/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
+++ b/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
@@ -23,6 +23,7 @@ import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
@@ -175,6 +176,10 @@ public class FileEntityStoreMixin
byte[] serializedState = fetch( f );
return new StringReader( new String( serializedState, "UTF-8" ) );
}
+ catch( FileNotFoundException e ){
+ // Can't happen, but it does happen.
+ throw new EntityNotFoundException( entityReference );
+ }
catch( IOException e )
{
throw new EntityStoreException( e );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/725b616f/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
index 47ff667..cab3481 100644
--- a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
+++ b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
@@ -21,6 +21,7 @@ package org.apache.zest.library.rest.client;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
+import org.apache.zest.api.type.HasTypes;
import org.apache.zest.api.usecase.UsecaseBuilder;
import org.hamcrest.CoreMatchers;
import org.junit.After;
@@ -598,7 +599,7 @@ public class ContextResourceClientFactoryTest
public void beforeCompletion()
throws UnitOfWorkCompletionException
{
- throw new ConcurrentEntityModificationException( Collections.<EntityComposite>emptyList(),
+ throw new ConcurrentEntityModificationException( Collections.<EntityComposite, HasTypes>emptyMap(),
UsecaseBuilder.newUsecase( "Testing" ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/725b616f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
index a92ee2b..08eb627 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
@@ -36,7 +36,6 @@ import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
import org.apache.zest.library.scheduler.Schedule;
import org.apache.zest.library.scheduler.Scheduler;
import org.apache.zest.library.scheduler.SchedulerConfiguration;
@@ -47,7 +46,6 @@ import org.apache.zest.library.scheduler.SchedulerConfiguration;
* The composite is internal and should never be used by clients.
*/
@Mixins( Execution.ExecutionMixin.class )
-@Concerns( UnitOfWorkConcern.class )
public interface Execution
{
void dispatchForExecution( Schedule schedule );
@@ -58,7 +56,6 @@ public interface Execution
void stop()
throws Exception;
- @UnitOfWorkPropagation( usecase = "Schedule Next Time Update" )
void updateNextTime( ScheduleTime schedule ); // This method is public, only because the UnitOfWorkConcern is wanted.
class ExecutionMixin
@@ -166,15 +163,15 @@ public interface Execution
public void updateNextTime( ScheduleTime oldScheduleTime )
{
long now = System.currentTimeMillis();
- UnitOfWork uow = module.currentUnitOfWork();
- try
+
+ try (UnitOfWork uow = module.newUnitOfWork()) // This will discard() the UoW when block is exited. We are only doing reads, so fine.
{
submitTaskForExecution( oldScheduleTime );
Schedule schedule = uow.get( Schedule.class, oldScheduleTime.scheduleIdentity() );
long nextTime = schedule.nextRun( now + 1000 );
if( nextTime != Long.MIN_VALUE )
{
- ScheduleTime newScheduleTime = new ScheduleTime( schedule.identity().get(), nextTime );
+ ScheduleTime newScheduleTime = new ScheduleTime( oldScheduleTime.scheduleIdentity(), nextTime );
synchronized( lock )
{
// Re-add to the Timing Queue, to re-position the sorting.