brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BROOKLYN-305) Rebind fails when entity attribute contains special unicode character "&#x1b;"
Date Wed, 22 Jun 2016 15:53:58 GMT

    [ https://issues.apache.org/jira/browse/BROOKLYN-305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15344581#comment-15344581
] 

ASF GitHub Bot commented on BROOKLYN-305:
-----------------------------------------

Github user bostko commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/214#discussion_r68080375
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterToObjectStore.java
---
    @@ -294,7 +294,7 @@ public void visit(BrooklynObjectType type, String id, String contentsSubpath)
th
                         exceptionHandler.onLoadMementoFailed(type, "memento "+id+" read error",
e);
                     }
                     
    -                String xmlId = (String) XmlUtil.xpath(contents, "/"+type.toCamelCase()+"/id");
    +                String xmlId = (String) XmlUtil.xpathHandlingIllegalChars(contents, "/"+type.toCamelCase()+"/id");
    --- End diff --
    
    Would `xpathHandlingIllegalChars` escape mechanism will be appropariate for filenames?
    Ideally if a function like `File.escapeSpecialChars` exists then this should look like
`File.escapeSpecialChars(XmlUtil.xpathHandlingIllegalChars(contents, "/"+type.toCamelCase()+"/id"))`


> Rebind fails when entity attribute contains special unicode character "&#x1b;"
> ------------------------------------------------------------------------------
>
>                 Key: BROOKLYN-305
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-305
>             Project: Brooklyn
>          Issue Type: Bug
>    Affects Versions: 0.9.0
>            Reporter: Aled Sage
>
> I had an entity with a sensor value that contained unicode character 27 (in the persisted
state, this was converted to by xstream to {{&#x1b;}} and written to the xml file).
> On restarting Brooklyn, it failed to restart. This is because {{&#x1b;}} is an illegal
character in xml. The xstream deserialization works fine, but our code first uses xpath to
extract the entity id from the raw xml. That fails with the exception below:
> {noformat}
> 2016-06-22 09:17:09,555 ERROR o.a.b.l.common.BasicLauncher [main]: Subsystem for persistence
had startup error (continuing with startup): org.apache.brooklyn.util.exceptions.PropagatedRuntimeException:
Failure rebinding; 3 errors including: problem loading memento: memento X2C3QT87 loading raw
error: SAXParseException: Character reference "&#
> org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
>         at org.apache.brooklyn.util.exceptions.Exceptions.propagate(Exceptions.java:128)
~[brooklyn-utils-common-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebind(RebindManagerImpl.java:507)
~[brooklyn-clocker-patches-1.2.0-20160609.1043.jar:1.2.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.ha.HighAvailabilityManagerImpl.promoteToMaster(HighAvailabilityManagerImpl.java:836)
~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.ha.HighAvailabilityManagerImpl.checkMaster(HighAvailabilityManagerImpl.java:810)
~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.ha.HighAvailabilityManagerImpl.publishAndCheck(HighAvailabilityManagerImpl.java:592)
~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.ha.HighAvailabilityManagerImpl.changeMode(HighAvailabilityManagerImpl.java:315)
~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.ha.HighAvailabilityManagerImpl.start(HighAvailabilityManagerImpl.java:255)
~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.launcher.common.BasicLauncher.startPersistence(BasicLauncher.java:644)
[brooklyn-launcher-common-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.launcher.common.BasicLauncher.handlePersistence(BasicLauncher.java:506)
[brooklyn-launcher-common-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.launcher.common.BasicLauncher.start(BasicLauncher.java:424)
[brooklyn-launcher-common-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.cli.Main$LaunchCommand.call(Main.java:461) [brooklyn-cli-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.cli.Main$LaunchCommand.call(Main.java:196) [brooklyn-cli-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.cli.AbstractMain.execCli(AbstractMain.java:252) [brooklyn-cli-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.cli.AbstractMain.execCli(AbstractMain.java:244) [brooklyn-cli-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at io.cloudsoft.amp.Main.main(Main.java:39) [amp-launcher-3.2.1.jar:na]
> Caused by: java.util.concurrent.ExecutionException: org.apache.brooklyn.util.exceptions.CompoundRuntimeException:
Failure rebinding; 3 errors including: problem loading memento: memento X2C3QT87 loading raw
error: SAXParseException: Character reference "&#
>         at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:1.8.0_91]
>         at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[na:1.8.0_91]
>         at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)
~[guava-16.0.1.jar:na]
>         at org.apache.brooklyn.util.core.task.BasicTask.get(BasicTask.java:361) ~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebind(RebindManagerImpl.java:505)
~[brooklyn-clocker-patches-1.2.0-20160609.1043.jar:1.2.0-20160609.1043]
>         ... 13 common frames omitted
> org.apache.brooklyn.util.exceptions.CompoundRuntimeException: Failure rebinding; 3 errors
including: problem loading memento: memento X2C3QT87 loading raw error: SAXParseException:
Character reference "&#
>         at org.apache.brooklyn.util.exceptions.Exceptions.create(Exceptions.java:393)
~[brooklyn-utils-common-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onDoneImpl(RebindExceptionHandlerImpl.java:497)
~[brooklyn-core-0.10.0-20160609.1043.jar:1.2.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onDone(RebindExceptionHandlerImpl.java:413)
~[brooklyn-core-0.10.0-20160609.1043.jar:1.2.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.run(RebindIteration.java:267)
~[brooklyn-core-0.10.0-20160609.1043.jar:1.2.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebindImpl(RebindManagerImpl.java:552)
~[brooklyn-clocker-patches-1.2.0-20160609.1043.jar:1.2.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:502)
~[brooklyn-clocker-patches-1.2.0-20160609.1043.jar:1.2.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:500)
~[brooklyn-clocker-patches-1.2.0-20160609.1043.jar:1.2.0-20160609.1043]
>         at org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:519)
~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_91]
>         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
~[na:1.8.0_91]
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
~[na:1.8.0_91]
>         at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_91]
> Caused by: java.lang.IllegalStateException: problem loading memento: memento X2C3QT87
loading raw error
>         at org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onLoadMementoFailed(RebindExceptionHandlerImpl.java:178)
~[brooklyn-core-0.10.0-20160609.1043.jar:1.2.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.persist.BrooklynMementoPersisterToObjectStore$1VisitorWrapper.run(BrooklynMementoPersisterToObjectStore.java:455)
~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_91]
>         ... 4 common frames omitted
> Caused by: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
>         at org.apache.brooklyn.util.exceptions.Exceptions.propagate(Exceptions.java:128)
~[brooklyn-utils-common-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.util.core.xstream.XmlUtil.xpath(XmlUtil.java:51) ~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.persist.BrooklynMementoPersisterToObjectStore$2.visit(BrooklynMementoPersisterToObjectStore.java:297)
~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         at org.apache.brooklyn.core.mgmt.persist.BrooklynMementoPersisterToObjectStore$1VisitorWrapper.run(BrooklynMementoPersisterToObjectStore.java:452)
~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         ... 5 common frames omitted
> Caused by: org.xml.sax.SAXParseException: Character reference "&#
>         at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
~[na:1.8.0_91]
>         at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
~[na:1.8.0_91]
>         at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) ~[na:1.8.0_91]
>         at org.apache.brooklyn.util.core.xstream.XmlUtil.xpath(XmlUtil.java:42) ~[brooklyn-core-0.10.0-20160609.1043.jar:0.10.0-20160609.1043]
>         ... 7 common frames omitted
> {noformat}
> The workaround is to replace this character in the persisted state (after first backing
it up, obviously!):
> {noformat}
> tar czf persisted-state.tgz persisted-state/
> cd persisted-state/
> find . -type f -exec sed -i.bak 's/&#x1b;/X/g' {} \;
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message