[ 
https://issues.jenkins-ci.org/browse/JENKINS-13865?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jason Howk updated JENKINS-13865:
---------------------------------

    Description: 
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 

{noformat}
[8mha:AAAAkB+LCAAAAAAAAABb85aBtbiIQSajNKU4P08vOT+vOD8nVc+jsiC1KCczL9svvyT1dMUiOWdZ/mImBiZPBrac1Lz0kgwfBubSopwSBiGfrMSyRP2cxLx0/eCSosy8dOuKIgYpNOOcITTIMAYIYGRiYKgoADLYShgE9JPzcwtKS1KL9HNKk1PzUgENqikilQAAAA==[0mlucene"
{noformat}

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:

{noformat}
public String getShortDescription() {
            return 
Messages.Queue_WaitingForNextAvailableExecutorOn(HyperlinkNote.encodeTo("/computer/"+
 node.getNodeName(), node.getNodeName()));
        }
{noformat}

The nodename is attempting to be encoded with HyperlinkNote:

{noformat}
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;
        }
    }
{noformat}

Which calls the supers encode() method:

{noformat}
public String encode() throws IOException {
        return encodeToBytes().toString();
    }
{noformat}

And finally encodeToBytes():

{noformat}
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;
    }
{noformat}

Finally in ConsoleNote
{noformat}
public static final String PREAMBLE_STR = "\u001B[8mha:";
public static final String POSTAMBLE_STR = "\u001B[0m";
}
{noformat}

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.


  was:
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 

{noformat}
[8mha:AAAAkB+LCAAAAAAAAABb85aBtbiIQSajNKU4P08vOT+vOD8nVc+jsiC1KCczL9svvyT1dMUiOWdZ/mImBiZPBrac1Lz0kgwfBubSopwSBiGfrMSyRP2cxLx0/eCSosy8dOuKIgYpNOOcITTIMAYIYGRiYKgoADLYShgE9JPzcwtKS1KL9HNKk1PzUgENqikilQAAAA==[0mlucene"
{noformat}

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:

{noformat}
public String getShortDescription() {
            return 
Messages.Queue_WaitingForNextAvailableExecutorOn(HyperlinkNote.encodeTo("/computer/"+
 node.getNodeName(), node.getNodeName()));
        }
{noformat}

The nodename is attempting to be encoded with HyperlinkNote:

{noformat}
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;
        }
    }
{noformat}

Which calls the supers encode() method:

{noformat}
public String encode() throws IOException {
        return encodeToBytes().toString();
    }
{noformat}

And finally encodeToBytes():

{noformat}
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;
    }
{noformat}

Finally in ConsoleNote
{noformat}
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.


    
> Jenkins /queue/api does not produce properly formatted JSON when a build in 
> queue where the destination node/s are busy.
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: JENKINS-13865
>                 URL: https://issues.jenkins-ci.org/browse/JENKINS-13865
>             Project: Jenkins
>          Issue Type: Bug
>          Components: core
>    Affects Versions: current
>         Environment: Linux
>            Reporter: Jason Howk
>
> 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 
> {noformat}
> [8mha:AAAAkB+LCAAAAAAAAABb85aBtbiIQSajNKU4P08vOT+vOD8nVc+jsiC1KCczL9svvyT1dMUiOWdZ/mImBiZPBrac1Lz0kgwfBubSopwSBiGfrMSyRP2cxLx0/eCSosy8dOuKIgYpNOOcITTIMAYIYGRiYKgoADLYShgE9JPzcwtKS1KL9HNKk1PzUgENqikilQAAAA==[0mlucene"
> {noformat}
> 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:
> {noformat}
> public String getShortDescription() {
>             return 
> Messages.Queue_WaitingForNextAvailableExecutorOn(HyperlinkNote.encodeTo("/computer/"+
>  node.getNodeName(), node.getNodeName()));
>         }
> {noformat}
> The nodename is attempting to be encoded with HyperlinkNote:
> {noformat}
> 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;
>         }
>     }
> {noformat}
> Which calls the supers encode() method:
> {noformat}
> public String encode() throws IOException {
>         return encodeToBytes().toString();
>     }
> {noformat}
> And finally encodeToBytes():
> {noformat}
> 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;
>     }
> {noformat}
> Finally in ConsoleNote
> {noformat}
> public static final String PREAMBLE_STR = "\u001B[8mha:";
> public static final String POSTAMBLE_STR = "\u001B[0m";
> }
> {noformat}
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to