COMPOUND WTF TEST
-
Application I'm working on is basically a message bus. Upstream server sends us a message, we insert it in the database, package it up and send it on to somebody else. The following code snippet is used to read data from a file and put it on the input queue (testing purposes, fixing production issues).
<FONT color=#7f0055>if</FONT>(((source.getMessageData()).toString()).contains(<FONT color=#2a00ff>"<WTFOrder xmlns:xsi="</FONT>) == <FONT color=#7f0055>true</FONT>)
{<FONT color=#0000c0>session</FONT>.begin();
endpoint.putMessage(source, <FONT color=#7f0055>false</FONT>, 0);
<FONT color=#3f7f5f>// COMPOUND TRANSACTION TEST
</FONT><FONT color=#3f7f5f>// endpoint2.putMessage(outmsg, false, 0);
</FONT><FONT color=#0000c0>session</FONT>.commit();}
<FONT color=#7f0055>if</FONT>(((source.getMessageData()).toString()).contains(<FONT color=#2a00ff>"<WTFWrittenData xmlns:xsi="</FONT>) == <FONT color=#7f0055>true</FONT>)
{<FONT color=#0000c0>session</FONT>.begin();
endpoint.putMessage(source, <FONT color=#7f0055>false</FONT>, 0);
<FONT color=#3f7f5f>// COMPOUND TRANSACTION TEST
</FONT><FONT color=#3f7f5f>// endpoint2.putMessage(outmsg, false, 0);
</FONT><FONT color=#0000c0>session</FONT>.commit();}
<FONT color=#7f0055>if</FONT>(((source.getMessageData()).toString()).contains(<FONT color=#2a00ff>"<WTFOrder>"</FONT>) == <FONT color=#7f0055>true</FONT>)
{<FONT color=#0000c0>session</FONT>.begin();
endpoint.putMessage(source, <FONT color=#7f0055>false</FONT>, 0);
<FONT color=#3f7f5f>// COMPOUND TRANSACTION TEST
</FONT><FONT color=#3f7f5f>// endpoint2.putMessage(outmsg, false, 0);
</FONT><FONT color=#0000c0>session</FONT>.commit();}
(WTF replaces acronym to protect the guilty, obviously)
I really want to assume there used to be different code in each of those blocks, but the fact that the commented out stuff is identical too....?
-
Well, it is possible they used to be different and then changed so they were all the same, resulting in a copy past that included comments. But still...
-
Hmmm...
if (someObject.toString().contains("xxx")) { ...}
as opposed to
if (someObject.getXxx() != null) { ... }
Seems like a lot of pointless toString'ing
-
I like the fact that if the input string contains more than one matching value, it will be inserted multiple times.
-
Re: CPOUND WTF TEST
Did anyone else read this as a CPound WTF TEST?
-
Maybe their compiler doesn't support the light-pole without a light operator.
-
if (expression == true) { /* shoot myself */ ; }
-
if if == then then then() else else()
-
if (x != y) {
i = x;
dosomething(c);
} else {
i = y;
dosome...err hold on, why did I have an if here?!
-
The real WTF is that the session handling is not guarded by try-finally. Otherwise it looks good :D
-
The real WTF is that they are not using an XML parser.
-
@dasluq said:
The real WTF is that they are not using an XML parser.
Nah, the data's coming in as a string and going out as a string. Parsing the whole thing to search for that one substring would lower performance.
The real WTF is that the session handling is not guarded by try-finally.
That code came from the inside of a try block.