Skip to content

Commit

Permalink
rollback core changes
Browse files Browse the repository at this point in the history
cleanup

cleanup

cleanup
  • Loading branch information
kliushnichenko committed Aug 24, 2024
1 parent 951a459 commit 646f355
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 63 deletions.
24 changes: 6 additions & 18 deletions jooby/src/main/java/io/jooby/DefaultContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.time.Instant;
import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

import jakarta.validation.ConstraintViolation;
import jakarta.validation.ConstraintViolationException;
import jakarta.validation.Validator;
import org.slf4j.Logger;

import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down Expand Up @@ -416,20 +417,7 @@ default boolean isSecure() {
T result = ValueConverters.convert(body(), type, getRouter());
return result;
}
T object = (T) decoder(contentType).decode(this, type);

MessageValidator messageValidator = getRouter().getMessageValidator();
if (messageValidator != null) {
if (messageValidator.predicate().test(type)) {
Validator validator = messageValidator.validator();
Set<ConstraintViolation<T>> violations = validator.validate(object);
if (!violations.isEmpty()) {
throw new ConstraintViolationException(violations);
}
}
}
return object;

return (T) decoder(contentType).decode(this, type);
} catch (Exception x) {
throw SneakyThrows.propagate(x);
}
Expand Down
15 changes: 0 additions & 15 deletions jooby/src/main/java/io/jooby/Jooby.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Type;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -42,7 +41,6 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import jakarta.validation.Validator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -629,19 +627,6 @@ public Jooby decoder(@NonNull MediaType contentType, @NonNull MessageDecoder dec
return this;
}

@NonNull
@Override
public Router messageValidator(@NonNull Validator validator, @NonNull Predicate<Type> predicate) {
router.messageValidator(validator, predicate);
return this;
}

@Nullable
@Override
public MessageValidator getMessageValidator() {
return router.getMessageValidator();
}

@NonNull @Override
public Jooby encoder(@NonNull MediaType contentType, @NonNull MessageEncoder encoder) {
router.encoder(contentType, encoder);
Expand Down
9 changes: 0 additions & 9 deletions jooby/src/main/java/io/jooby/MessageValidator.java

This file was deleted.

4 changes: 0 additions & 4 deletions jooby/src/main/java/io/jooby/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static java.util.Collections.unmodifiableList;
import static java.util.Objects.requireNonNull;

import java.lang.reflect.Type;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -29,7 +28,6 @@
import java.util.stream.IntStream;
import java.util.stream.Stream;

import jakarta.validation.Validator;
import org.slf4j.Logger;

import com.typesafe.config.Config;
Expand Down Expand Up @@ -510,8 +508,6 @@ default Object execute(@NonNull Context context) {
*/
@NonNull Router decoder(@NonNull MediaType contentType, @NonNull MessageDecoder decoder);

@NonNull Router messageValidator(@NonNull Validator validator, @NonNull Predicate<Type> predicate);
@Nullable MessageValidator getMessageValidator();
/**
* Returns the worker thread pool. This thread pool is used to run application blocking code.
*
Expand Down
16 changes: 0 additions & 16 deletions jooby/src/main/java/io/jooby/internal/RouterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static java.util.Objects.requireNonNull;

import java.io.FileNotFoundException;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
Expand Down Expand Up @@ -36,7 +35,6 @@
import java.util.stream.IntStream;
import java.util.stream.Stream;

import jakarta.validation.Validator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -149,8 +147,6 @@ public Stack executor(Executor executor) {

private Map<String, MessageDecoder> decoders = new HashMap<>();

private MessageValidator messageValidator = null;

private Map<String, Object> attributes = new ConcurrentHashMap<>();

private ServiceRegistry services = new ServiceRegistryImpl();
Expand Down Expand Up @@ -372,18 +368,6 @@ public Router decoder(@NonNull MediaType contentType, @NonNull MessageDecoder de
return this;
}

@NonNull
@Override
public Router messageValidator(@NonNull Validator validator, @NonNull Predicate<Type> predicate) {
this.messageValidator = new MessageValidator(validator, predicate);
return this;
}

@Override
public MessageValidator getMessageValidator() {
return messageValidator;
}

@NonNull @Override
public Executor getWorker() {
return worker;
Expand Down
1 change: 0 additions & 1 deletion jooby/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* True core deps
*/
requires jakarta.inject;
requires jakarta.validation;
requires org.slf4j;
requires static com.github.spotbugs.annotations;
requires typesafe.config;
Expand Down

0 comments on commit 646f355

Please sign in to comment.