Skip to content

Commit e9e48d2

Browse files
committed
Merge branch 'release/0.16.2'
2 parents 1026e5b + 3e38cf2 commit e9e48d2

File tree

85 files changed

+375
-179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+375
-179
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [0.16.2] - 2021-12-14
9+
* Bump vert.x to 4.2.2
10+
* Pretty print polyglot exceptions so IDEs can track back
11+
* Allow multiple maven repositories (comma separated)
12+
813
## [0.16.1] - 2021-11-10
914
* Bump vert.x to 4.2.1
1015
* Fixed codegen for data objects to properly handle collection types

codegen/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<parent>
55
<groupId>io.reactiverse</groupId>
66
<artifactId>es4x-parent</artifactId>
7-
<version>0.16.1</version>
7+
<version>0.16.2</version>
88
<relativePath>..</relativePath>
99
</parent>
1010

1111
<modelVersion>4.0.0</modelVersion>
1212

1313
<artifactId>es4x-codegen</artifactId>
14-
<version>0.16.1</version>
14+
<version>0.16.2</version>
1515

1616
<properties>
1717
<tools.jar>${java.home}/../lib/tools.jar</tools.jar>

es4x/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<parent>
55
<groupId>io.reactiverse</groupId>
66
<artifactId>es4x-parent</artifactId>
7-
<version>0.16.1</version>
7+
<version>0.16.2</version>
88
<relativePath>..</relativePath>
99
</parent>
1010

1111
<modelVersion>4.0.0</modelVersion>
1212

1313
<artifactId>es4x</artifactId>
14-
<version>0.16.1</version>
14+
<version>0.16.2</version>
1515

1616
<properties>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

es4x/src/main/java/io/reactiverse/es4x/jul/ANSIFormatter.java

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,22 @@
1515
*/
1616
package io.reactiverse.es4x.jul;
1717

18+
import io.reactiverse.es4x.sourcemap.SourceMap;
19+
import io.vertx.core.buffer.Buffer;
20+
import io.vertx.core.json.Json;
21+
import io.vertx.core.json.JsonObject;
22+
import org.graalvm.polyglot.PolyglotException;
23+
import org.graalvm.polyglot.SourceSection;
24+
1825
import java.io.IOException;
1926
import java.io.PrintWriter;
2027
import java.io.StringWriter;
28+
import java.net.URI;
29+
import java.nio.file.Files;
30+
import java.nio.file.Paths;
31+
import java.util.Collections;
32+
import java.util.IdentityHashMap;
33+
import java.util.Set;
2134
import java.util.logging.*;
2235

2336
import static java.util.logging.Level.*;
@@ -26,6 +39,7 @@ public class ANSIFormatter extends Formatter {
2639

2740
// are ANSI colors allowed?
2841
private static final boolean colors;
42+
// private static final SourceMap sourceMap;
2943

3044
static {
3145
if (Boolean.getBoolean("noTTY")) {
@@ -48,6 +62,14 @@ public class ANSIFormatter extends Formatter {
4862
colors = System.console() != null;
4963
}
5064
}
65+
//
66+
// // handle source maps
67+
// String sourceMapFile = System.getProperty("sourceMap");
68+
// if (sourceMapFile != null) {
69+
// sourceMap = new SourceMap(Buffer.buffer(Files.readAllBytes(Paths.get(sourceMapFile))));
70+
// } else {
71+
// sourceMap = null;
72+
// }
5173
}
5274

5375
@Override
@@ -151,4 +173,104 @@ private static String suffix(Level l) {
151173

152174
return "";
153175
}
176+
177+
178+
private static final String CAUSE_CAPTION = "Caused by: ";
179+
private static final String SUPPRESSED_CAPTION = "Suppressed: ";
180+
181+
public static void printStackTrace(Throwable self, PrintWriter s) {
182+
// Guard against malicious overrides of Throwable.equals by
183+
// using a Set with identity equality semantics.
184+
Set<Throwable> dejaVu = Collections.newSetFromMap(new IdentityHashMap<>());
185+
dejaVu.add(self);
186+
187+
// Print our stack trace
188+
s.println(self);
189+
StackTraceElement[] trace = self.getStackTrace();
190+
printTrace(self, trace, trace.length, s);
191+
192+
// Print suppressed exceptions, if any
193+
for (Throwable se : self.getSuppressed())
194+
printEnclosedStackTrace(se, s, trace, SUPPRESSED_CAPTION, "\t", dejaVu);
195+
196+
// Print cause, if any
197+
Throwable ourCause = self.getCause();
198+
if (ourCause != null)
199+
printEnclosedStackTrace(ourCause, s, trace, CAUSE_CAPTION, "", dejaVu);
200+
}
201+
202+
private static void printEnclosedStackTrace(
203+
Throwable self,
204+
PrintWriter s,
205+
StackTraceElement[] enclosingTrace,
206+
String caption,
207+
String prefix,
208+
Set<Throwable> dejaVu) {
209+
210+
if (dejaVu.contains(self)) {
211+
s.println(prefix + caption + "[CIRCULAR REFERENCE: " + self + "]");
212+
} else {
213+
dejaVu.add(self);
214+
// Compute number of frames in common between this and enclosing trace
215+
StackTraceElement[] trace = self.getStackTrace();
216+
int m = trace.length - 1;
217+
int n = enclosingTrace.length - 1;
218+
while (m >= 0 && n >= 0 && trace[m].equals(enclosingTrace[n])) {
219+
m--;
220+
n--;
221+
}
222+
int framesInCommon = trace.length - 1 - m;
223+
224+
// Print our stack trace
225+
s.println(prefix + caption + self);
226+
printTrace(self, trace, m, s);
227+
228+
if (framesInCommon != 0)
229+
s.println(prefix + "\t... " + framesInCommon + " more");
230+
231+
// Print suppressed exceptions, if any
232+
for (Throwable se : self.getSuppressed())
233+
printEnclosedStackTrace(se, s, trace, SUPPRESSED_CAPTION,
234+
prefix + "\t", dejaVu);
235+
236+
// Print cause, if any
237+
Throwable ourCause = self.getCause();
238+
if (ourCause != null)
239+
printEnclosedStackTrace(ourCause, s, trace, CAUSE_CAPTION, prefix, dejaVu);
240+
}
241+
}
242+
243+
private static void printTrace(Throwable self, StackTraceElement[] trace, int limit, PrintWriter s) {
244+
if (self instanceof PolyglotException) {
245+
int i = 0;
246+
for (PolyglotException.StackFrame stackFrame : ((PolyglotException) self).getPolyglotStackTrace()) {
247+
if (i++ == limit) {
248+
break;
249+
}
250+
if (stackFrame.isHostFrame()) {
251+
s.println("\tat " + stackFrame);
252+
} else {
253+
SourceSection sourceSection = stackFrame.getSourceLocation();
254+
if (sourceSection != null) {
255+
URI uri = sourceSection.getSource().getURI();
256+
257+
// TODO: rewrite with sourcemap is available
258+
259+
s.println("\tat <js> " + stackFrame.getRootName()
260+
+ "(" +
261+
("file".equals(uri.getScheme()) ? uri.getPath() : uri) +
262+
(sourceSection.hasLines() ? ":" + sourceSection.getStartLine() : "") +
263+
(sourceSection.hasColumns() ? ":" + sourceSection.getStartColumn() : "") +
264+
")");
265+
} else {
266+
s.println("\tat " + stackFrame);
267+
}
268+
}
269+
}
270+
} else {
271+
for (int i = 0; i <= limit; i++) {
272+
s.println("\tat " + trace[i]);
273+
}
274+
}
275+
}
154276
}

es4x/src/main/java/io/reactiverse/es4x/sourcemap/SourceMap.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package io.reactiverse.es4x.sourcemap;
22

3-
import io.vertx.core.json.Json;
3+
import io.vertx.core.buffer.Buffer;
44
import io.vertx.core.json.JsonArray;
55
import io.vertx.core.json.JsonObject;
66

77
import java.util.ArrayList;
8-
import java.util.Arrays;
98
import java.util.Collection;
109
import java.util.List;
1110

@@ -21,15 +20,15 @@ public class SourceMap {
2120
private ArrayList<ArrayList<Mapping>> lines = null;
2221
private String sourceRoot;
2322

24-
public SourceMap(String sourceMapData) {
23+
public SourceMap(byte[] sourceMapData) {
2524
parse(sourceMapData);
2625
}
2726

2827
/**
2928
* Parses the given contents containing a source map.
3029
*/
31-
private void parse(String sourceMapData) {
32-
JsonObject sourceMapRoot = new JsonObject(sourceMapData);
30+
private void parse(byte[] sourceMapData) {
31+
JsonObject sourceMapRoot = new JsonObject(Buffer.buffer(sourceMapData));
3332

3433
// Check basic assertions about the format.
3534
int version = sourceMapRoot.getInteger("version");

es4x/src/test/java/io/reactiverse/es4x/MappingTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package io.reactiverse.es4x;
22

3-
import io.reactiverse.es4x.impl.VertxFileSystem;
43
import io.reactiverse.es4x.sourcemap.SourceMap;
5-
import io.vertx.core.Vertx;
6-
import org.graalvm.polyglot.io.FileSystem;
74
import org.junit.Test;
85

96
import java.io.File;
@@ -37,9 +34,8 @@ public void testMapping() throws IOException {
3734

3835

3936

40-
SourceMap source = new SourceMap(new String(
41-
Files.readAllBytes(new File("src/test/resources/bundle.js.map").toPath())
42-
));
37+
SourceMap source = new SourceMap(
38+
Files.readAllBytes(new File("src/test/resources/bundle.js.map").toPath()));
4339

4440
source.eachMapping(System.out::println);
4541

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package io.reactiverse.es4x.test;
2+
3+
import io.reactiverse.es4x.jul.ANSIFormatter;
4+
import io.vertx.ext.unit.Async;
5+
import io.vertx.ext.unit.TestContext;
6+
import io.vertx.ext.unit.junit.RunTestOnContext;
7+
import io.vertx.ext.unit.junit.VertxUnitRunner;
8+
import org.junit.AfterClass;
9+
import org.junit.BeforeClass;
10+
import org.junit.Rule;
11+
import org.junit.Test;
12+
import org.junit.runner.RunWith;
13+
14+
import java.io.IOException;
15+
import java.io.PrintWriter;
16+
import java.io.StringWriter;
17+
import java.util.logging.Level;
18+
import java.util.logging.LogRecord;
19+
20+
@RunWith(VertxUnitRunner.class)
21+
public class JULFormatterTest {
22+
23+
@BeforeClass
24+
public static void before() {
25+
//System.setProperty("es4x.host.class.filter", "io.vertx.**,java.util.**,java.time.**,java.lang.**,java.net.**,io.reactiverse.es4x.**,!java.nio.file.FileAlreadyExistsException");
26+
System.setProperty("es4x.host.class.filter", "!java.nio.file.FileAlreadyExistsException");
27+
}
28+
29+
@AfterClass
30+
public static void after() {
31+
System.getProperties().remove("es4x.host.class.filter");
32+
}
33+
34+
@Rule
35+
public RunTestOnContext rule = new RunTestOnContext();
36+
37+
@Test(timeout = 10000)
38+
public void shouldDeployVerticle(TestContext ctx) {
39+
final Async async = ctx.async();
40+
rule.vertx().deployVerticle("js:./verticle3.js", deploy -> {
41+
ctx.assertFalse(deploy.succeeded());
42+
ANSIFormatter formatter = new ANSIFormatter();
43+
LogRecord item = new LogRecord(Level.ALL, "message");
44+
item.setThrown(deploy.cause());
45+
String out = formatter.format(item);
46+
System.out.println(out);
47+
48+
try (StringWriter sw = new StringWriter()) {
49+
PrintWriter pw = new PrintWriter(sw);
50+
ANSIFormatter.printStackTrace(deploy.cause(), pw);
51+
System.out.println(sw);
52+
} catch (IOException e) {
53+
// ignore
54+
}
55+
async.complete();
56+
});
57+
}
58+
}

generator/io.reactiverse/elasticsearch-client/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
<parent>
99
<groupId>io.reactiverse.es4x</groupId>
1010
<artifactId>es4x-generator</artifactId>
11-
<version>0.16.1</version>
11+
<version>0.16.2</version>
1212
<relativePath>../..</relativePath>
1313
</parent>
1414

1515
<artifactId>elasticsearch-client</artifactId>
16-
<version>0.16.1</version>
16+
<version>0.16.2</version>
1717

1818
<packaging>jar</packaging>
1919

generator/io.reactiverse/reactiverse-contextual-logging/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
<parent>
99
<groupId>io.reactiverse.es4x</groupId>
1010
<artifactId>es4x-generator</artifactId>
11-
<version>0.16.1</version>
11+
<version>0.16.2</version>
1212
<relativePath>../..</relativePath>
1313
</parent>
1414

1515
<artifactId>reactiverse-contextual-logging</artifactId>
16-
<version>0.16.1</version>
16+
<version>0.16.2</version>
1717

1818
<packaging>jar</packaging>
1919

@@ -29,7 +29,7 @@
2929
}
3030
</npm-dependencies>
3131
<logback.version>1.2.3</logback.version>
32-
<log4j2.version>2.14.0</log4j2.version>
32+
<log4j2.version>2.15.0</log4j2.version>
3333
</properties>
3434

3535
<dependencies>

generator/io.vertx/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
<parent>
99
<groupId>io.reactiverse</groupId>
1010
<artifactId>es4x-parent</artifactId>
11-
<version>0.16.1</version>
11+
<version>0.16.2</version>
1212
<relativePath>../..</relativePath>
1313
</parent>
1414

1515
<artifactId>es4x-vertx-stack</artifactId>
16-
<version>0.16.1</version>
16+
<version>0.16.2</version>
1717

1818
<dependencies>
1919
<dependency>

0 commit comments

Comments
 (0)