Comments (8)
Figured I would just confirm: simply omitting the throwable
argument from the super
call works fine. So that would read
public JSONRPCException(final CODE code, final String description, final Throwable t) {
super(description);
init(code, description, t);
}
from eve.
Hi Erik,
Which release/version are you referring to? In the Master I've done a fix that probably fixes your mentioned issue, but it had not been ported back to 2.2.1 as it was contained in a larger unrelated commit. I'll patch 2.2.1 now, can you check if that helps?
from eve.
Hi Ludo,
Thanks! I think the extra clause you added to init()
, namely to check that getCause() == null
before attempting to call initCause
should work fine in most cases. However if we called the JSONRPCException
constructor with the Throwable
argument set to null
(which according to the java docs is actually a reasonable thing to do) then it will still go wrong.
This latter cornercase might be a minor advantage of my suggested fix -- simply not passing the t
argument to the super constructor -- compared to this extra test inside init
.
from eve.
@ludost Sorry didn't mean to close it just yet, at least until you read my comment :-)
from eve.
@ludost Looking at the source for Throwable
it looks like the test getCause()==null
will not work... http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/java/lang/Throwable.java#Throwable
The cause field is initialized to this
, not null
, so I expect your test will not do what it should when one of the constructors without a throwable is used.
So I guess the way to get this working properly for all constructor variants is not to pass any throwable to the super constructor and remove the getCause()
test from init
?
from eve.
The problem is that super(t)
is different than setCause(t)
. And I like to have the behaviour of super(t)
:)
But back to your statement, which is incorrect: the getCause()==null
will work:
public synchronized Throwable getCause() {
return (cause==this ? null : cause);
}
So, please test my latest commit in your code, I believe it will fix the issue.
PS: I fail to see why putting a null-cause would lead to a problem? Throwable seems to handle that case correctly in its constructors and hopefully JSONRPCException as well.
from eve.
Ah, I had not noticed this quirk in getCause
. I did test it, actually, and my immediate problem is resolved. I still wonder about calling a constructor with t==null
but as far as I know we're not doing that.
Thanks!
Oh and just curious, what is the difference between super(t)
and setCause(t)
that you mentioned?
from eve.
An indication about the safety of the constructors is this statement from one of these constructors:
detailMessage = (cause==null ? null : cause.toString());
Which explicitly checks for null causes.
from eve.
Related Issues (20)
- URL selection change to Map HOT 2
- Several classes not found when running on older Android (I am trying 2.2 / api 8) HOT 1
- getMethods gives null pointer HOT 2
- getServletRegistrations() no such method HOT 1
- Eve-Java: Parameter with a confusing name in Scheduler.createTask
- Plans for a Ruby implementation? HOT 2
- JAVA: Possible bug with @Required(false) parameters HOT 2
- Http Calls fail HOT 1
- christos HOT 1
- UUID NoClassDefFoundError exceptions HOT 2
- JSONRPCException: Couldn't handle XMPP return causing Android ANR errors HOT 4
- Share one xmpp connection (address) over multiple agents HOT 1
- Adding External Jars HOT 2
- Platform shutdown method HOT 1
- Release 2.2.1 HOT 2
- EVE 2.2.0 setRemoveOnCancelPolicy error on Android < 4.4 HOT 5
- Create/Destroy eve agents through methods HOT 1
- @Name for methods? HOT 1
- Obtain the access tag value via JSON-RPC HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eve.