X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FRobustIdentifiable.java;fp=impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FRobustIdentifiable.java;h=6622e3277a85e35ae2dbf527bac761ae07f1d3e9;hb=75f42f00e16ceee9ea333e598c9287de20ede1c3;hp=640e37e13385402e9414c6beb2719bb3d6e2d378;hpb=3cb88352bdfd5454043a6ee1369330d1fd4aa0dd;p=xmlrouter diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java index 640e37e..6622e32 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java @@ -15,10 +15,13 @@ */ package org.wamblee.xmlrouter.impl; +import static org.wamblee.xmlrouter.impl.MessageUtil.*; + import java.util.logging.Level; import java.util.logging.Logger; import org.wamblee.xmlrouter.common.Id; +import org.wamblee.xmlrouter.config.ConfigException; import org.wamblee.xmlrouter.config.Identifiable; /** @@ -38,26 +41,25 @@ public class RobustIdentifiable implements Identifiable { // TODO test that id is constant even though delegated changes its id. public RobustIdentifiable(String aPrefix, Identifiable aIdentifiable) { + notNull("prefix", aPrefix); + notNull("identifiable", aIdentifiable); // TODO test id is null // TODO getId() throws exception try { id = aIdentifiable.getId(); if (id == null) { - id = new Id(Constants.UNKNOWN_ID.toString()); - temporarilyThrowException(); - } else { - id = new Id(aPrefix + id.getId()); + throwConfigException("identifiable.getId() returned null", null); } + id = new Id(aPrefix + id.getId()); } catch (Exception e) { - LOGGER - .log(Level.WARNING, "Identifiable getId() threw exception", e); + throwConfigException("identifiable.getId() threw exception", e); } } - private void temporarilyThrowException() { - throw new RuntimeException( - "Temporary to catch nulls during refactoring"); + private void throwConfigException(String aMsg, Exception aException) { + LOGGER.log(Level.WARNING, aMsg, aException); + throw new ConfigException("id is null"); } @Override