Le 24/03/2017 à 14:13, Jacopo Cappellato a écrit :
On Fri, Mar 24, 2017 at 10:56 AM, Jacques Le Roux <
[email protected]> wrote:
[...]
If we (both and All) agree on collaborating to document on purpose
swallowed exceptions, even when you are not directly concerned, then I
agree to revert my changes, deal?
We are not negotiating: I have simply asked you to revert the changes in
which you have changed the functional behavior of the system without
testing OR test the new behavior and confirm it is working fine.
I thought you could have given some information on the documentation to put
into the swallowed exceptions :/
In general I like the effort of improving this old code containing
swallowed exceptions by providing more comments, documentation etc... or
completely refactoring it; but this has to be done with proper testing.
I hope this clarifies my request.
Jacopo
OK so I'll try to answer to your request.
No need to say that all the tests pass. We know we don't directly cover all services but at least we got that when running all tests (gradlew
testIntegration):
2017-03-24 14:33:03,864 |main |ServiceDispatcher |T| Sync service [test-dispatcher-Oz3Z0DRojV/updateProductionRunTask] finished in [830]
milliseconds
2017-03-24 14:33:04,173 |main |ServiceDispatcher |T| Sync service [test-dispatcher-Oz3Z0DRojV/updateProductionRunTask] finished in [162]
milliseconds
It's part of testProductionRunQuickIssueAndProduce through a call to
productionRunDeclareAndProduce itself calling updateProductionRunTask
I think we can agree that the successful behaviour can't have been derailed by my changes. It's only when a GenericEntityException or
GenericServiceException is raised that it might be have been changed, right? So at least in a normal situation (no exceptions) it's OK.
Now what happens when an exception is raised?
In case of a GenericEntityException 2 expressions are concerned. In case of issues it's better to catch them rather than ignore them. Nothing was done
before, it was simply ignored. How could let a GenericEntityException swallowed here be better? It's better now IMO, shit happens, better not let it
hits the fan.
In case of a GenericServiceException the sync call to
issueProductionRunTaskComponent is concerned. It's a simple-method.
Here are the 2 cases in log when putting a typo in
issueProductionRunTaskComponent
With exception handled:
2017-03-24 20:29:38,267 |main |ServiceDispatcher |T| [[Sync service failed...- total:0.0,since last(Begin):0.0]] -
'test-dispatcher-m10o2bxhIR / issueProductionRunTaskComponent'
2017-03-24 20:29:38,267 |main |TransactionUtil |W| Calling
transaction setRollbackOnly; this stack trace shows where this is happening:
java.lang.Exception: Service [issueProductionRunTaskComponent] threw an
unexpected exception/error
at
org.apache.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:361)
[ofbiz.jar:?]
at
org.apache.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:302)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:512)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:227)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.GenericDispatcherFactory$GenericDispatcher.runSync(GenericDispatcherFactory.java:88)
[ofbiz.jar:?]
at
org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRunServices.updateProductionRunTask(ProductionRunServices.java:2210)
[ofbiz.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[?:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
~[?:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
~[?:1.8.0_121]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
at
org.apache.ofbiz.service.engine.StandardJavaEngine.serviceInvoker(StandardJavaEngine.java:100)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.engine.StandardJavaEngine.runSync(StandardJavaEngine.java:57)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:395)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:227)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.GenericDispatcherFactory$GenericDispatcher.runSync(GenericDispatcherFactory.java:88)
[ofbiz.jar:?]
at
org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRunServices.productionRunDeclareAndProduce(ProductionRunServices.java:1882)
[ofbiz.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[?:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
~[?:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
~[?:1.8.0_121]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
at
org.apache.ofbiz.service.engine.StandardJavaEngine.serviceInvoker(StandardJavaEngine.java:100)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.engine.StandardJavaEngine.runSync(StandardJavaEngine.java:57)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:395)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:227)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.GenericDispatcherFactory$GenericDispatcher.runSync(GenericDispatcherFactory.java:103)
[ofbiz.jar:?]
at
org.apache.ofbiz.minilang.method.callops.CallService.exec(CallService.java:217)
[ofbiz.jar:?]
at
org.apache.ofbiz.minilang.SimpleMethod.runSubOps(SimpleMethod.java:310)
[ofbiz.jar:?]
at org.apache.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:457)
[ofbiz.jar:?]
at
org.apache.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:274)
[ofbiz.jar:?]
at
org.apache.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:287)
[ofbiz.jar:?]
at
org.apache.ofbiz.testtools.SimpleMethodTest.run(SimpleMethodTest.java:85)
[ofbiz.jar:?]
at junit.framework.TestSuite.runTest(TestSuite.java:243)
[junit-dep-4.10.jar:?]
at junit.framework.TestSuite.run(TestSuite.java:238)
[junit-dep-4.10.jar:?]
at
org.apache.ofbiz.testtools.TestRunContainer.start(TestRunContainer.java:152)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.container.ContainerLoader.startLoadedContainers(ContainerLoader.java:148)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:73)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.start.StartupControlPanel.loadStartupLoaders(StartupControlPanel.java:202)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:69)
[ofbiz.jar:?]
at org.apache.ofbiz.base.start.Start.main(Start.java:84) [ofbiz.jar:?]
2017-03-24 20:29:38,273 |main |ProductionRunServices |E| Problem
calling the updateProductionRunTaskStatus service
org.apache.ofbiz.service.GenericServiceException: Error running simple method [issueProductionRunTaskComponent] in XML file
[component://manufacturing/minilang/jobshopmgt/ProductionRunServices.xml]: (Could n
ot read SimpleMethod XML document [file:/C:/projectsASF/ofbiz-framework/applications/manufacturing/minilang/jobshopmgt/ProductionRunServices.xml]:
(The value of attribute "value-field" associated with an ele
ment type "entity-one" must not contain the '<' character.))
with exception swallowed
2017-03-24 20:50:03,596 |main |ServiceDispatcher |T| [[Sync service failed...- total:0.0,since last(Begin):0.0]] -
'test-dispatcher-T7iFbK65R2 / issueProductionRunTaskComponent'
2017-03-24 20:50:03,596 |main |TransactionUtil |W| Calling
transaction setRollbackOnly; this stack trace shows where this is happening:
java.lang.Exception: Service [issueProductionRunTaskComponent] threw an
unexpected exception/error
at
org.apache.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:361)
[ofbiz.jar:?]
at
org.apache.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:302)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:512)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:227)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.GenericDispatcherFactory$GenericDispatcher.runSync(GenericDispatcherFactory.java:88)
[ofbiz.jar:?]
at
org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRunServices.updateProductionRunTask(ProductionRunServices.java:2210)
[ofbiz.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[?:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
~[?:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
~[?:1.8.0_121]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
at
org.apache.ofbiz.service.engine.StandardJavaEngine.serviceInvoker(StandardJavaEngine.java:100)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.engine.StandardJavaEngine.runSync(StandardJavaEngine.java:57)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:395)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:227)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.GenericDispatcherFactory$GenericDispatcher.runSync(GenericDispatcherFactory.java:88)
[ofbiz.jar:?]
at
org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRunServices.productionRunDeclareAndProduce(ProductionRunServices.java:1882)
[ofbiz.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[?:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
~[?:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
~[?:1.8.0_121]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
at
org.apache.ofbiz.service.engine.StandardJavaEngine.serviceInvoker(StandardJavaEngine.java:100)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.engine.StandardJavaEngine.runSync(StandardJavaEngine.java:57)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:395)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:227)
[ofbiz.jar:?]
at
org.apache.ofbiz.service.GenericDispatcherFactory$GenericDispatcher.runSync(GenericDispatcherFactory.java:103)
[ofbiz.jar:?]
at
org.apache.ofbiz.minilang.method.callops.CallService.exec(CallService.java:217)
[ofbiz.jar:?]
at
org.apache.ofbiz.minilang.SimpleMethod.runSubOps(SimpleMethod.java:310)
[ofbiz.jar:?]
at org.apache.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:457)
[ofbiz.jar:?]
at
org.apache.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:274)
[ofbiz.jar:?]
at
org.apache.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:287)
[ofbiz.jar:?]
at
org.apache.ofbiz.testtools.SimpleMethodTest.run(SimpleMethodTest.java:85)
[ofbiz.jar:?]
at junit.framework.TestSuite.runTest(TestSuite.java:243)
[junit-dep-4.10.jar:?]
at junit.framework.TestSuite.run(TestSuite.java:238)
[junit-dep-4.10.jar:?]
at
org.apache.ofbiz.testtools.TestRunContainer.start(TestRunContainer.java:152)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.container.ContainerLoader.startLoadedContainers(ContainerLoader.java:148)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:73)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.start.StartupControlPanel.loadStartupLoaders(StartupControlPanel.java:202)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:69)
[ofbiz.jar:?]
at org.apache.ofbiz.base.start.Start.main(Start.java:84) [ofbiz.jar:?]
2017-03-24 20:50:03,600 |main |ServiceEcaRule |I| For Service ECA [workEffortGenericPermission] on [return] got false for condition:
[hasPermission][equals][false][true][Boolean
]
2017-03-24 20:50:03,600 |main |ServiceDispatcher |T| Sync service [test-dispatcher-T7iFbK65R2/workEffortGenericPermission] finished in [1]
milliseconds
2017-03-24 20:50:03,600 |main |TransactionUtil |W| Active transaction marked for rollback in place, so no transaction begun; this stack
trace shows when the exception began:
java.lang.Exception: Tx Stack Placeholder
at
org.apache.ofbiz.entity.transaction.TransactionUtil.setTransactionBeginStack(TransactionUtil.java:720)
~[ofbiz.jar:?]
at
org.apache.ofbiz.entity.transaction.TransactionUtil.begin(TransactionUtil.java:156)
~[ofbiz.jar:?]
at
org.apache.ofbiz.entity.transaction.TransactionUtil.begin(TransactionUtil.java:111)
~[ofbiz.jar:?]
at org.apache.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:441)
[ofbiz.jar:?]
at
org.apache.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:274)
[ofbiz.jar:?]
at
org.apache.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:287)
[ofbiz.jar:?]
at
org.apache.ofbiz.testtools.SimpleMethodTest.run(SimpleMethodTest.java:85)
[ofbiz.jar:?]
at junit.framework.TestSuite.runTest(TestSuite.java:243)
[junit-dep-4.10.jar:?]
at junit.framework.TestSuite.run(TestSuite.java:238)
[junit-dep-4.10.jar:?]
at
org.apache.ofbiz.testtools.TestRunContainer.start(TestRunContainer.java:152)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.container.ContainerLoader.startLoadedContainers(ContainerLoader.java:148)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:73)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.start.StartupControlPanel.loadStartupLoaders(StartupControlPanel.java:202)
[ofbiz.jar:?]
at
org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:69)
[ofbiz.jar:?]
at org.apache.ofbiz.base.start.Start.main(Start.java:84) [ofbiz.jar:?]
2017-03-24 20:50:03,632 |main |UtilProperties |I| ResourceBundle
MiniLangErrorUiLabels (en) created in 0.031s with 4 properties
2017-03-24 20:50:03,632 |main |ServiceDispatcher |E| Error in Service [updateWorkEffort]: Error trying to begin transaction, could not
process method: The current transaction is ma
rked for rollback, not beginning a new transaction and aborting current operation; the rollbackOnly was caused by: Service
[issueProductionRunTaskComponent] threw an unexpected exception/errororg.apache.ofbiz
.service.GenericServiceException: Error running simple method [issueProductionRunTaskComponent] in XML file
[component://manufacturing/minilang/jobshopmgt/ProductionRunServices.xml]: (Could not read SimpleMe
thod XML document [file:/C:/projectsASF/ofbiz-framework/applications/manufacturing/minilang/jobshopmgt/ProductionRunServices.xml]: (The value of
attribute "value-field" associated with an element type "entit
y-one" must not contain the '<' character.)) (Error running simple method [issueProductionRunTaskComponent] in XML file
[component://manufacturing/minilang/jobshopmgt/ProductionRunServices.xml]: (Could not r
ead SimpleMethod XML document [file:/C:/projectsASF/ofbiz-framework/applications/manufacturing/minilang/jobshopmgt/ProductionRunServices.xml]: (The
value of attribute "value-field" associated with an element
type "entity-one" must not contain the '<' character.)))
I'd argue that the 1st stack is easier to understand. I could continue on other cases but they are simpler and it's not my intention to defend my
commit when we have so much other tasks pending. Oh boys, I hoped more collaboration...
Now feel free to revert my commit if you still think it's a bad thing, but sincerely I'm not convinced! If you do so I'll then at least add comments
to explain the situation...
Jacques