Skip to content

Commit 431ce9c

Browse files
committed
Rename Sneaky -> SneakyThrows
1 parent 28b6755 commit 431ce9c

File tree

40 files changed

+161
-167
lines changed

40 files changed

+161
-167
lines changed

docs/src/main/java/io/jooby/adoc/DocGenerator.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
package io.jooby.adoc;
77

8-
import io.jooby.Sneaky;
8+
import io.jooby.SneakyThrows;
99
import org.apache.commons.io.FileUtils;
1010
import org.asciidoctor.Asciidoctor;
1111
import org.asciidoctor.Attributes;
@@ -16,9 +16,6 @@
1616
import org.jsoup.nodes.Document;
1717
import org.jsoup.nodes.Element;
1818
import org.jsoup.nodes.TextNode;
19-
import org.jsoup.select.Elements;
20-
import org.slf4j.Logger;
21-
import org.slf4j.LoggerFactory;
2219

2320
import java.io.IOException;
2421
import java.nio.charset.StandardCharsets;
@@ -27,10 +24,8 @@
2724
import java.nio.file.Paths;
2825
import java.nio.file.StandardCopyOption;
2926
import java.util.LinkedHashSet;
30-
import java.util.LinkedList;
3127
import java.util.UUID;
3228
import java.util.stream.Collectors;
33-
import java.util.stream.Stream;
3429

3530
public class DocGenerator {
3631
public static void main(String[] args) throws Exception {
@@ -70,7 +65,7 @@ public static void generate(Path basedir, boolean publish) throws Exception {
7065

7166
// post process
7267
Files.walk(outdir).filter(it -> it.getFileName().toString().endsWith("index.html"))
73-
.forEach(Sneaky.throwingConsumer(it -> {
68+
.forEach(SneakyThrows.throwingConsumer(it -> {
7469
Files.write(it, document(it).getBytes(StandardCharsets.UTF_8));
7570
}));
7671

jooby/src/main/java/io/jooby/Asset.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ public FileAsset(@Nonnull Path file) {
4747
try {
4848
return Files.size(file);
4949
} catch (IOException x) {
50-
throw Sneaky.propagate(x);
50+
throw SneakyThrows.propagate(x);
5151
}
5252
}
5353

5454
@Override public long getLastModified() {
5555
try {
5656
return Files.getLastModifiedTime(file).toMillis();
5757
} catch (IOException x) {
58-
throw Sneaky.propagate(x);
58+
throw SneakyThrows.propagate(x);
5959
}
6060
}
6161

@@ -67,7 +67,7 @@ public FileAsset(@Nonnull Path file) {
6767
try {
6868
return new FileInputStream(file.toFile());
6969
} catch (IOException x) {
70-
throw Sneaky.propagate(x);
70+
throw SneakyThrows.propagate(x);
7171
}
7272
}
7373

@@ -177,7 +177,7 @@ private void checkOpen() {
177177
content = connection.getInputStream();
178178
}
179179
} catch (IOException x) {
180-
throw Sneaky.propagate(x);
180+
throw SneakyThrows.propagate(x);
181181
}
182182
}
183183
}

jooby/src/main/java/io/jooby/AssetSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ public interface AssetSource {
7878
} else if (Files.isRegularFile(location)) {
7979
return new FileDiskAssetSource(location);
8080
}
81-
throw Sneaky.propagate(new FileNotFoundException(location.toAbsolutePath().toString()));
81+
throw SneakyThrows.propagate(new FileNotFoundException(location.toAbsolutePath().toString()));
8282
}
8383
}

jooby/src/main/java/io/jooby/AttachedFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public AttachedFile(@Nonnull InputStream content, @Nonnull String fileName, long
6060
this.content = content;
6161
this.fileSize = fileSize;
6262
} catch (UnsupportedEncodingException x) {
63-
throw Sneaky.propagate(x);
63+
throw SneakyThrows.propagate(x);
6464
}
6565
}
6666

jooby/src/main/java/io/jooby/Context.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ default long getRequestLength() {
792792
try {
793793
return parser(contentType).parse(this, type.getType());
794794
} catch (Exception x) {
795-
throw Sneaky.propagate(x);
795+
throw SneakyThrows.propagate(x);
796796
}
797797
}
798798

@@ -819,7 +819,7 @@ default long getRequestLength() {
819819
try {
820820
return parser(contentType).parse(this, type);
821821
} catch (Exception x) {
822-
throw Sneaky.propagate(x);
822+
throw SneakyThrows.propagate(x);
823823
}
824824
}
825825

@@ -1069,7 +1069,7 @@ default long getRequestLength() {
10691069
send(bytes);
10701070
return this;
10711071
} catch (Exception x) {
1072-
throw Sneaky.propagate(x);
1072+
throw SneakyThrows.propagate(x);
10731073
}
10741074
}
10751075

@@ -1100,7 +1100,7 @@ default long getRequestLength() {
11001100
* @throws Exception Is something goes wrong.
11011101
*/
11021102
default @Nonnull Context responseStream(@Nonnull MediaType contentType,
1103-
@Nonnull Sneaky.Consumer<OutputStream> consumer) throws Exception {
1103+
@Nonnull SneakyThrows.Consumer<OutputStream> consumer) throws Exception {
11041104
setResponseType(contentType);
11051105
return responseStream(consumer);
11061106
}
@@ -1112,7 +1112,7 @@ default long getRequestLength() {
11121112
* @return HTTP channel as output stream. Usually for chunked responses.
11131113
* @throws Exception Is something goes wrong.
11141114
*/
1115-
default @Nonnull Context responseStream(@Nonnull Sneaky.Consumer<OutputStream> consumer)
1115+
default @Nonnull Context responseStream(@Nonnull SneakyThrows.Consumer<OutputStream> consumer)
11161116
throws Exception {
11171117
try (OutputStream out = responseStream()) {
11181118
consumer.accept(out);
@@ -1162,7 +1162,7 @@ default long getRequestLength() {
11621162
* @return This context.
11631163
* @throws Exception Is something goes wrong.
11641164
*/
1165-
default @Nonnull Context responseWriter(@Nonnull Sneaky.Consumer<PrintWriter> consumer)
1165+
default @Nonnull Context responseWriter(@Nonnull SneakyThrows.Consumer<PrintWriter> consumer)
11661166
throws Exception {
11671167
return responseWriter(MediaType.text, consumer);
11681168
}
@@ -1176,7 +1176,7 @@ default long getRequestLength() {
11761176
* @throws Exception Is something goes wrong.
11771177
*/
11781178
default @Nonnull Context responseWriter(@Nonnull MediaType contentType,
1179-
@Nonnull Sneaky.Consumer<PrintWriter> consumer) throws Exception {
1179+
@Nonnull SneakyThrows.Consumer<PrintWriter> consumer) throws Exception {
11801180
return responseWriter(contentType, contentType.getCharset(), consumer);
11811181
}
11821182

@@ -1190,7 +1190,7 @@ default long getRequestLength() {
11901190
* @throws Exception Is something goes wrong.
11911191
*/
11921192
default @Nonnull Context responseWriter(@Nonnull MediaType contentType, @Nullable Charset charset,
1193-
@Nonnull Sneaky.Consumer<PrintWriter> consumer) throws Exception {
1193+
@Nonnull SneakyThrows.Consumer<PrintWriter> consumer) throws Exception {
11941194
try (PrintWriter writer = responseWriter(contentType, charset)) {
11951195
consumer.accept(writer);
11961196
}
@@ -1313,7 +1313,7 @@ default long getRequestLength() {
13131313
setDefaultResponseType(MediaType.byFile(file));
13141314
return send(FileChannel.open(file));
13151315
} catch (IOException x) {
1316-
throw Sneaky.propagate(x);
1316+
throw SneakyThrows.propagate(x);
13171317
}
13181318
}
13191319

@@ -1360,8 +1360,8 @@ default long getRequestLength() {
13601360
.error("error handler resulted in exception {} {}", getMethod(), pathString(), x);
13611361
}
13621362
/** rethrow fatal exceptions: */
1363-
if (Sneaky.isFatal(cause)) {
1364-
throw Sneaky.propagate(cause);
1363+
if (SneakyThrows.isFatal(cause)) {
1364+
throw SneakyThrows.propagate(cause);
13651365
}
13661366
return this;
13671367
}

jooby/src/main/java/io/jooby/Cookie.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public long getMaxAge() {
376376
byte[] bytes = mac.doFinal(value.getBytes());
377377
return Base64.getEncoder().withoutPadding().encodeToString(bytes) + "|" + value;
378378
} catch (Exception x) {
379-
throw Sneaky.propagate(x);
379+
throw SneakyThrows.propagate(x);
380380
}
381381
}
382382

@@ -422,7 +422,7 @@ public long getMaxAge() {
422422
}
423423
return joiner.toString();
424424
} catch (UnsupportedEncodingException x) {
425-
throw Sneaky.propagate(x);
425+
throw SneakyThrows.propagate(x);
426426
}
427427
}
428428

@@ -460,7 +460,7 @@ public long getMaxAge() {
460460

461461
return attributes.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(attributes);
462462
} catch (UnsupportedEncodingException x) {
463-
throw Sneaky.propagate(x);
463+
throw SneakyThrows.propagate(x);
464464
}
465465
}
466466

jooby/src/main/java/io/jooby/Jooby.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ public class Jooby implements Router, Registry {
7777

7878
private Path tmpdir;
7979

80-
private List<Sneaky.Runnable> readyCallbacks;
80+
private List<SneakyThrows.Runnable> readyCallbacks;
8181

82-
private List<Sneaky.Runnable> startingCallbacks;
82+
private List<SneakyThrows.Runnable> startingCallbacks;
8383

8484
private LinkedList<AutoCloseable> stopCallbacks;
8585

@@ -184,7 +184,7 @@ public Jooby() {
184184
* @param body Start body.
185185
* @return This application.
186186
*/
187-
public @Nonnull Jooby onStarting(@Nonnull Sneaky.Runnable body) {
187+
public @Nonnull Jooby onStarting(@Nonnull SneakyThrows.Runnable body) {
188188
if (startingCallbacks == null) {
189189
startingCallbacks = new ArrayList<>();
190190
}
@@ -199,7 +199,7 @@ public Jooby() {
199199
* @param body Start body.
200200
* @return This application.
201201
*/
202-
public @Nonnull Jooby onStarted(@Nonnull Sneaky.Runnable body) {
202+
public @Nonnull Jooby onStarted(@Nonnull SneakyThrows.Runnable body) {
203203
if (readyCallbacks == null) {
204204
readyCallbacks = new ArrayList<>();
205205
}
@@ -317,7 +317,7 @@ public Jooby renderer(@Nonnull MediaType contentType, @Nonnull Renderer renderer
317317
try {
318318
extension.install(this);
319319
} catch (Exception x) {
320-
throw Sneaky.propagate(x);
320+
throw SneakyThrows.propagate(x);
321321
}
322322
}
323323
return this;
@@ -555,7 +555,7 @@ public Jooby errorCode(@Nonnull Class<? extends Throwable> type,
555555
log.info("Server stop resulted in exception", stopx);
556556
}
557557
// rethrow
558-
throw Sneaky.propagate(x);
558+
throw SneakyThrows.propagate(x);
559559
}
560560
}
561561

@@ -822,15 +822,15 @@ private static void ensureTmpdir(Path tmpdir) {
822822
Files.createDirectories(tmpdir);
823823
}
824824
} catch (IOException x) {
825-
throw Sneaky.propagate(x);
825+
throw SneakyThrows.propagate(x);
826826
}
827827
}
828828

829-
private List<Sneaky.Runnable> fire(List<Sneaky.Runnable> tasks) {
829+
private List<SneakyThrows.Runnable> fire(List<SneakyThrows.Runnable> tasks) {
830830
if (tasks != null) {
831-
Iterator<Sneaky.Runnable> iterator = tasks.iterator();
831+
Iterator<SneakyThrows.Runnable> iterator = tasks.iterator();
832832
while (iterator.hasNext()) {
833-
Sneaky.Runnable task = iterator.next();
833+
SneakyThrows.Runnable task = iterator.next();
834834
task.run();
835835
iterator.remove();
836836
}
@@ -870,7 +870,7 @@ private static Supplier<Jooby> reflectionProvider(
870870
(Jooby) Stream.of(applicationType.getDeclaredConstructors())
871871
.filter(it -> it.getParameterCount() == 0)
872872
.findFirst()
873-
.map(Sneaky.throwingFunction(c -> c.newInstance()))
873+
.map(SneakyThrows.throwingFunction(c -> c.newInstance()))
874874
.orElseThrow(() -> new IllegalArgumentException(
875875
"Default constructor for: " + applicationType.getName()));
876876
}
@@ -890,7 +890,7 @@ private void joobyRunHook(ClassLoader loader, Server server) {
890890
Consumer consumer = (Consumer) parent.loadClass(hookClassname).newInstance();
891891
consumer.accept(server);
892892
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException x) {
893-
throw Sneaky.propagate(x);
893+
throw SneakyThrows.propagate(x);
894894
}
895895
}
896896
}

jooby/src/main/java/io/jooby/ServerOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ private int randomPort() {
370370
try (ServerSocket socket = new ServerSocket(0)) {
371371
return socket.getLocalPort();
372372
} catch (IOException x) {
373-
throw Sneaky.propagate(x);
373+
throw SneakyThrows.propagate(x);
374374
}
375375
}
376376
}

0 commit comments

Comments
 (0)