Time |
S |
Nick |
Message |
03:22 |
|
|
sivoais joined #sourcefu |
15:25 |
|
pdurbin |
I finally got this working the way I want: http://stackoverflow.com/questions/23007567/java-json-pretty-print-javax-json/25206426#25206426 |
16:39 |
|
semiosis |
pdurbin: bonus points if you can make it work through JAXB |
16:39 |
|
semiosis |
(i gave up on that though) |
16:39 |
|
pdurbin |
hmm |
16:39 |
|
pdurbin |
I'm not quite sure what that means |
16:40 |
|
pdurbin |
it works for me... that's all i know :) |
16:40 |
|
semiosis |
by through JAXB i mean, you return an object & Jersey serializes, instead of you serializing & giving Jersey the string |
16:40 |
|
pdurbin |
oh, I see. hmm |
16:41 |
|
pdurbin |
no idea |
16:41 |
|
semiosis |
lol |
16:41 |
|
semiosis |
i'm pretty sure it's possible in theory, but i never could get it to work right |
16:42 |
|
pdurbin |
semiosis: you should see the reaction from pythonistas over in #rest: http://irclog.greptilian.com/rest/2014-08-08#i_72599 :) |
16:43 |
|
semiosis |
ha |
16:45 |
|
semiosis |
re JAXB, this is the doc: https://jersey.java.net/documentation/1.18/json.html |
16:45 |
|
semiosis |
if you're using jersey 1 |
16:45 |
|
semiosis |
not that i'd recommed it, but just fyi |
17:07 |
|
pdurbin |
right. I've played with this a bit |
17:07 |
|
pdurbin |
haven't tried to pretty print it |
17:29 |
|
pdurbin |
semiosis: do you use JPA at all? |
18:03 |
|
semiosis |
tons |
18:04 |
|
pdurbin |
how about findbugs or checkstyle? |
18:04 |
|
semiosis |
sonarqube |
18:05 |
|
pdurbin |
searchbot: lucky sonarqube |
18:05 |
|
searchbot |
pdurbin: http://www.sonarqube.org/ |
18:05 |
|
pdurbin |
is this thing free and open source? |
18:05 |
|
semiosis |
you can see the public sonar instance i set up for the glusterfs-java project here: http://sonar.peircean.com/ |
18:05 |
|
semiosis |
yes |
18:05 |
|
pdurbin |
nice |
18:05 |
|
pdurbin |
will check that out later |
18:05 |
|
pdurbin |
so |
18:06 |
|
semiosis |
there are some plugins that are commercial |
18:06 |
|
semiosis |
i use atlassian clover for the glusterfs project, which is commercial, but they give free (beer) licenses to FOSS projects |
18:06 |
|
pdurbin |
ok |
18:06 |
|
pdurbin |
back to JPA :) |
18:06 |
|
semiosis |
i tried all the coverage tools and clover was the only one that could handle it |
18:07 |
|
pdurbin |
you know how Query.getSingleResult() throws NoResultException? (and NonUniqueResultException) http://docs.oracle.com/javaee/7/api/javax/persistence/Query.html#getSingleResult%28%29 |
18:07 |
|
semiosis |
because i use things that meddle with the bytecode, lombok + powermock |
18:07 |
|
pdurbin |
(they're RuntimeException's) |
18:07 |
|
semiosis |
ok |
18:07 |
|
semiosis |
what about em |
18:09 |
|
pdurbin |
it means they should be caught my the method calling getSingleResult... caught and then return null rather than letting the RuntimeException bubble up to someone else's code |
18:10 |
|
pdurbin |
s/my/by/ |
18:10 |
|
semiosis |
hard to say. caller's code could just as easily fail to check for a null pointer as fail to catch an exception |
18:11 |
|
pdurbin |
let's assume everyone knows to check for null |
18:11 |
|
semiosis |
debugging the NURE/NRE would probably be easier than the NPE |
18:11 |
|
semiosis |
more direct |
18:12 |
|
pdurbin |
but let's assume that a RuntimeException is not something they expected when calling into a service bean |
18:12 |
|
semiosis |
personally, i would let the exception bubble out to the caller |
18:13 |
|
semiosis |
unless i was returning a count, then i would return 0 |
18:13 |
|
pdurbin |
even though it's a RuntimeException? you wouldn't at least catch the RuntimeException and throw a checked exception? Wouldn't that be nicer of you? |
18:14 |
|
semiosis |
hang on, let me see what we actually do |
18:15 |
|
pdurbin |
ok |
18:15 |
|
pdurbin |
then I'll get to my actual question :) |
18:17 |
|
semiosis |
we're using getSingleResult for count queries |
18:17 |
|
pdurbin |
do you do any catching of exceptions in there? |
18:17 |
|
semiosis |
when we want a single object we check the result list size & return the 0th item if it's not an empty set |
18:18 |
|
|
aditsu joined #sourcefu |
18:18 |
|
semiosis |
there's one place we do getsingleresult & return null in the catch NRE |
18:19 |
|
semiosis |
so inconsistent |
18:19 |
|
semiosis |
whats your actual question? |
18:19 |
|
pdurbin |
I think that's the right approach |
18:20 |
|
pdurbin |
catch the NoResultException and return null |
18:20 |
|
pdurbin |
or at least |
18:20 |
|
pdurbin |
don't let the RuntimeException blow up someone else's code |
18:20 |
|
pdurbin |
let's say I want to enforce this approach with findbugs or checkstyle or whatever... is this possible... can it find this? |
18:21 |
|
semiosis |
no idea |
18:21 |
|
semiosis |
of course, if you really care about other people calling your code, document all possible returns & exceptions in the javadoc |
18:22 |
|
pdurbin |
well |
18:22 |
|
pdurbin |
I want the opposite |
18:23 |
|
pdurbin |
I want other people to document exceptions they're allowing to bubble up, especially when they're unchecked exceptions. |
18:23 |
|
pdurbin |
sounds like maybe there isn't any easy way for findbugs to find this stuff. :( |
18:26 |
|
pdurbin |
the rule would be something like: if method A is called make sure that exception B is caught |
18:27 |
|
semiosis |
i think you'd need something that could look at the bytecode, not just a syntax style checker |
18:27 |
|
pdurbin |
hmm |
18:29 |
|
semiosis |
...because there's no syntax indicating unchecked exceptions |
18:30 |
|
pdurbin |
semiosis: which tool are you looking at? |
18:30 |
|
semiosis |
none, just thinking about it |
18:30 |
|
semiosis |
you cant tell from a method signature if any unchecked exception will be thrown |
18:31 |
|
semiosis |
so you'd need to look in its bytecode |
18:31 |
|
semiosis |
or source code |
18:31 |
|
pdurbin |
oh, I see, hmm |
20:16 |
|
pdurbin |
semiosis: more on the excpetions thing if you're interested: http://irclog.greptilian.com/friendlyjava/2014-08-08 |
20:23 |
|
semiosis |
pdurbin: i did a little googling around & didnt find anything promising. wonder how hard it would be to analyze the bytecode looking for RE constructor calls |
20:24 |
|
pdurbin |
sounds hard |
20:24 |
|
pdurbin |
anyway |
20:25 |
|
pdurbin |
at a high level, I'm thinking it would be good to have the team use findbugs or checkstyle or your thing |
20:26 |
|
semiosis |
http://docs.codehaus.org/display/SONAR/FindBugs+Plugin |
20:26 |
|
semiosis |
http://docs.codehaus.org/display/SONAR/Checkstyle+Plugin |
20:27 |
|
semiosis |
set up a sonarqube server, add a sonar profile to your maven POM, have jenkins run the sonar:sonar goal nightly |
20:27 |
|
semiosis |
then hook all the code quality metrics etc into sonar |
20:28 |
|
semiosis |
with plugins |
20:30 |
|
pdurbin |
lemme just run one of these tools locally first :) |
20:34 |
|
aditsu |
just for the record, there's another similar tool called pmd |
20:34 |
|
aditsu |
http://pmd.sourceforge.net/ |
20:34 |
|
semiosis |
http://docs.codehaus.org/display/SONAR/PMD+Plugin |
20:34 |
|
semiosis |
:) |
20:37 |
|
aditsu |
with pmd you can write your own rules using xpath on the syntax tree |
20:38 |
|
pdurbin |
oh right, pmd |
20:38 |
|
pdurbin |
I've heard of that one too |