-
Bug
-
Resolution: Fixed
-
Major
-
None
-
Linux
Jenkins /queue/api does not produce properly formatted JSON when build in queue where a node/s are fully busy. The json produced is un-parsable. This can be visible on the builds.apache.org server.
Example:
"why":"Waiting for next available executor on
[8mha:AAAAkB+LCAAAAAAAAABb85aBtbiIQSajNKU4P08vOT+vOD8nVc+jsiC1KCczL9svvyT1dMUiOWdZ/mImBiZPBrac1Lz0kgwfBubSopwSBiGfrMSyRP2cxLx0/eCSosy8dOuKIgYpNOOcITTIMAYIYGRiYKgoADLYShgE9JPzcwtKS1KL9HNKk1PzUgENqikilQAAAA==[0mlucene"
Appears that the "why" property of the queued build isn't being formatted properly. Actually it's being gzipped...
Looking at the source, the hudson.model.queue.CauseOfBlockage class appears to be the culprit. To wit:
public String getShortDescription() { return Messages.Queue_WaitingForNextAvailableExecutorOn(HyperlinkNote.encodeTo("/computer/"+ node.getNodeName(), node.getNodeName())); }
The nodename is attempting to be encoded with HyperlinkNote:
public static String encodeTo(String url, String text) { try { return new HyperlinkNote(url,text.length()).encode()+text; } catch (IOException e) { // impossible, but don't make this a fatal problem LOGGER.log(Level.WARNING, "Failed to serialize "+HyperlinkNote.class,e); return text; } }
Which calls the supers encode() method:
public String encode() throws IOException { return encodeToBytes().toString(); }
And finally encodeToBytes():
private ByteArrayOutputStream encodeToBytes() throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(new GZIPOutputStream(buf)); oos.writeObject(this); oos.close(); ByteArrayOutputStream buf2 = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(new Base64OutputStream(buf2,true,-1,null)); buf2.write(PREAMBLE); dos.writeInt(buf.size()); buf.writeTo(dos); dos.close(); buf2.write(POSTAMBLE); return buf2; }
Finally in ConsoleNote
public static final String PREAMBLE_STR = "\u001B[8mha:"; public static final String POSTAMBLE_STR = "\u001B[0m"; }
Clearly the choice in using ansi escaping, and therefore the brackets is violating the JSON structural syntax rules and causing the JSON emitted to be un-parsable.
One more update: This appears to be due to the chosen preamble/postamble chosen.
public static final String PREAMBLE_STR = "\u001B[8mha:";
public static final String POSTAMBLE_STR = "\u001B[0m";
Per RFC, JSON is unicode. (http://www.ietf.org/rfc/rfc4627) and the choice of the ascii control codes violates the JSON agreement (i.e. use of the brackets as they are structural characters)