Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ subprojects {
apply plugin: 'jacoco'
apply plugin: 'org.unbroken-dome.test-sets'

ext {
jvmVersion = JavaVersion.VERSION_1_8
}

sourceCompatibility = jvmVersion
targetCompatibility = jvmVersion
java.toolchain.languageVersion = JavaLanguageVersion.of(8)

compileJava.options.encoding = 'UTF-8'

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2022 - Alex Danilenko
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package spotty.common.exception;

public class SpottyRouteDuplicationException extends SpottyException {

public SpottyRouteDuplicationException(String message, Object... args) {
super(message, args);
}

}
6 changes: 3 additions & 3 deletions core/src/main/java/spotty/common/utils/Memoized.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private Memoized() {

public static <T> Supplier<T> lazy(Supplier<T> supplier) {
return new Supplier<T>() {
private T memoized;
private volatile T memoized;

@Override
public T get() {
Expand All @@ -41,8 +41,8 @@ public T get() {

public static IntSupplier lazy(IntSupplier supplier) {
return new IntSupplier() {
private boolean isMemoized = false;
private int value;
private volatile boolean isMemoized = false;
private volatile int value;

@Override
public int getAsInt() {
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/java/spotty/common/utils/RouterUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public static Result compileMatcher(String pathTemplate) {
}

public static String normalizePath(String path) {
return path.replaceAll(REGEX, "*$2");
if (!path.startsWith("/")) {
path = "/" + path;
}

return path.replaceAll(REGEX, "*$2")
.replaceAll("\\*+", "*");
}

public static class Result {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@
import org.apache.tika.Tika;

import java.net.URL;
import java.util.function.Supplier;

import static spotty.common.utils.Memoized.lazy;

public final class FileTypeDetector implements TypeDetector {

private final Tika tika = new Tika();
private static final Supplier<Tika> tika = lazy(() -> new Tika());

@Override
public String detect(URL path) throws Exception {
return tika.detect(path);
return tika.get().detect(path);
}

}
Loading