Repository: wicket
Updated Branches:
  refs/heads/master da98a830c -> eabc9bd44


WICKET-5518 simplified exception handling

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/eabc9bd4
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/eabc9bd4
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/eabc9bd4

Branch: refs/heads/master
Commit: eabc9bd4439295bdfd4a0236fdda2dd3557d1437
Parents: da98a83
Author: svenmeier <[email protected]>
Authored: Wed Feb 26 10:04:27 2014 +0100
Committer: svenmeier <[email protected]>
Committed: Wed Feb 26 10:04:27 2014 +0100

----------------------------------------------------------------------
 .../wicket/markup/html/form/FormComponent.java  | 22 +++++++-------------
 1 file changed, 8 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/eabc9bd4/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
index cb4ad05..ece95f1 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
@@ -1625,7 +1625,7 @@ public abstract class FormComponent<T> extends 
LabeledWebMarkupContainer impleme
                }
                else
                {
-                       Exception failure;
+                       boolean modified = false;
 
                        formComponent.modelChanging();
                        
@@ -1635,33 +1635,27 @@ public abstract class FormComponent<T> extends 
LabeledWebMarkupContainer impleme
                                {
                                        collection.addAll(convertedInput);
                                }
-                               failure = null;
+                               modified = true;
                        } catch (UnsupportedOperationException unmodifiable) {
-                               logger.debug("An error occurred while trying to 
change the collection attached to " + formComponent, unmodifiable);
+                               logger.debug("An error occurred while trying to 
modify the collection attached to " + formComponent, unmodifiable);
 
-                               failure = unmodifiable;
                                collection = new ArrayList<>(convertedInput); 
                        }
                        
                        try
                        {
                                formComponent.getModel().setObject(collection);
-                               failure = null;
                        }
                        catch (Exception noSetter)
                        {
-                               logger.debug("An error occurred while trying to 
set the collection attached to " + formComponent, noSetter);
-                               
-                               if (failure != null) {
-                                       failure = noSetter;
+                               if (modified) {
+                                       logger.debug("An error occurred while 
trying to set the collection attached to " + formComponent, noSetter);
+                               } else {
+                                       throw new WicketRuntimeException("An 
error occurred while trying to set the collection attached to " + 
formComponent, noSetter); 
                                }
                        }
                        
-                       if (failure == null) {
-                               formComponent.modelChanged();
-                       } else {
-                               throw new WicketRuntimeException("Unable to 
update the collection attached to " + formComponent); 
-                       }
+                       formComponent.modelChanged();
                }
        }
 }

Reply via email to