From 638bb9263d867f300123acc9023f27ee242e6079 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 18 Feb 2013 22:15:39 +0200 Subject: [PATCH] Fixed logic error causing IOException if stream supports mark (#10851) The current logic caused mark() never to be called if the original InputStream supports mark (isMarkSupported()). This in turn causes an IOException when reset is called and no mark has been set. Change-Id: I781ed8e9d355d22bd8e43acb5c5e9c8da90f66a0 --- .../vaadin/sass/internal/parser/Parser.java | 19 +++++++++++-------- .../com/vaadin/sass/internal/parser/Parser.jj | 4 +++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java index 928c889956..3863a30379 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java @@ -152,6 +152,7 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { /** * This method parses only one rule (style rule or at-rule, except + * * @charset). * * @param source @@ -314,10 +315,12 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { String encoding = source.getEncoding(); InputStream input = source.getByteStream(); if (!input.markSupported()) { + // If mark is not supported, wrap it in a stream which supports mark input = new BufferedInputStream(input); source.setByteStream(input); - input.mark(100); } + // Mark either the original stream or the wrapped stream + input.mark(100); if (encoding == null) { encoding = "ASCII"; @@ -6436,6 +6439,13 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } + private boolean jj_3R_252() { + if (jj_scan_token(HASH)) { + return true; + } + return false; + } + private boolean jj_3R_184() { if (jj_scan_token(SEMICOLON)) { return true; @@ -6451,13 +6461,6 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } - private boolean jj_3R_252() { - if (jj_scan_token(HASH)) { - return true; - } - return false; - } - private boolean jj_3R_239() { Token xsp; xsp = jj_scanpos; diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj index a0bd883101..1f9221de88 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj @@ -319,10 +319,12 @@ public class Parser implements org.w3c.css.sac.Parser { String encoding = source.getEncoding(); InputStream input = source.getByteStream(); if (!input.markSupported()) { + // If mark is not supported, wrap it in a stream which supports mark input = new BufferedInputStream(input); source.setByteStream(input); - input.mark(100); } + // Mark either the original stream or the wrapped stream + input.mark(100); if(encoding == null){ encoding = "ASCII"; -- 2.39.5