From 83feb6ad13187af9be55cc71408611f67d280955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Tue, 14 Jan 2020 21:28:10 +0100 Subject: Fix timestamps and ValueQuery --- .../java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/model') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java b/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java index ece50b5..3edda69 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java @@ -28,24 +28,30 @@ public class ValueQuery extends Value { */ public ValueQuery(String query) throws Exception { this.code = query; - Yylex lex = new Yylex(new ByteArrayInputStream(query.getBytes())); - this.query = (new parser(lex)).pProgram(); + if (!query.isEmpty()) { + Yylex lex = new Yylex(new ByteArrayInputStream(query.getBytes())); + this.query = (new parser(lex)).pProgram(); + } this.signature = null; this.timestamp = System.currentTimeMillis(); } public ValueQuery(String query, byte[] querySignature) throws Exception { this.code = query; - Yylex lex = new Yylex(new ByteArrayInputStream(query.getBytes())); - this.query = (new parser(lex)).pProgram(); + if (!query.isEmpty()) { + Yylex lex = new Yylex(new ByteArrayInputStream(query.getBytes())); + this.query = (new parser(lex)).pProgram(); + } this.signature = querySignature; this.timestamp = System.currentTimeMillis(); } public ValueQuery(QueryData queryData) throws Exception { this.code = queryData.getCode(); - Yylex lex = new Yylex(new ByteArrayInputStream(queryData.getCode().getBytes())); - this.query = (new parser(lex)).pProgram(); + if (!queryData.getCode().isEmpty()) { + Yylex lex = new Yylex(new ByteArrayInputStream(queryData.getCode().getBytes())); + this.query = (new parser(lex)).pProgram(); + } this.signature = queryData.getSignature(); this.timestamp = System.currentTimeMillis(); } -- cgit v1.2.3