Skip to content

Commit

Permalink
Merge pull request #15419 from gsmet/1.12.1-backports-4
Browse files Browse the repository at this point in the history
1.12.1 backports 4
  • Loading branch information
gsmet authored Mar 2, 2021
2 parents 92186ba + b3440e7 commit 3691945
Show file tree
Hide file tree
Showing 19 changed files with 99 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<sentry.version>4.1.0</sentry.version>
<subethasmtp.version>3.1.7</subethasmtp.version>
<hibernate-quarkus-local-cache.version>0.1.0</hibernate-quarkus-local-cache.version>
<kubernetes-client.version>5.1.0</kubernetes-client.version>
<kubernetes-client.version>5.1.1</kubernetes-client.version>
<flapdoodle.mongo.version>2.2.0</flapdoodle.mongo.version>
<quarkus-spring-api.version>5.2.SP4</quarkus-spring-api.version>
<quarkus-spring-data-api.version>2.1.SP2</quarkus-spring-data-api.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public void close() {
//the main entry point, but loaded inside the augmentation class loader
@Override
public void accept(CuratedApplication o, Map<String, Object> params) {
Timing.staticInitStarted(o.getBaseRuntimeClassLoader());
//https://github.com/quarkusio/quarkus/issues/9748
//if you have an app with all daemon threads then the app thread
//may be the only thread keeping the JVM alive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public class DevConsoleProcessor {

@BuildStep(onlyIf = IsDevelopment.class)
public DevConsoleRuntimeTemplateInfoBuildItem collectBeanInfo() {
return new DevConsoleRuntimeTemplateInfoBuildItem("entities", new HibernateSearchSupplier());
return new DevConsoleRuntimeTemplateInfoBuildItem("entityTypes", new HibernateSearchSupplier());
}

@BuildStep
@Record(value = STATIC_INIT, optional = true)
DevConsoleRouteBuildItem invokeEndpoint(HibernateSearchDevConsoleRecorder recorder) {
return new DevConsoleRouteBuildItem("entities", "POST", recorder.indexEntity());
return new DevConsoleRouteBuildItem("entity-types", "POST", recorder.indexEntity());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="{urlbase}/entities" class="badge badge-light">
<a href="{urlbase}/entity-types" class="badge badge-light">
<i class="fa fa-search fa-fw"></i>
Indexed entities <span class="badge badge-light">{info:entities.size()}</span></a>
Indexed entity types <span class="badge badge-light">{info:entityTypes.size()}</span></a>
<br>
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
<input type="checkbox" class="form-check-input" id="check-all">
</div>
</th>
<th scope="col">Entity</th>
<th scope="col">Entity type</th>
</tr>
</thead>
<tbody>
{#for entity in info:entities}
{#for entityType in info:entityTypes}
<tr>
<td>
<div class="custom-control">
<input type="checkbox" class="form-check-input checkbox" name="{entity}" id="{entity}">
<input type="checkbox" class="form-check-input checkbox" name="{entityType}" id="{entityType}">
</div>
</td>
<td>{entity}</td>
<td>{entityType}</td>
</tr>
{/for}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.hibernate.search.mapper.orm.mapping.SearchMapping;

import io.quarkus.devconsole.runtime.spi.DevConsolePostHandler;
import io.quarkus.devconsole.runtime.spi.FlashScopeUtil;
import io.quarkus.runtime.annotations.Recorder;
import io.vertx.core.Handler;
import io.vertx.core.MultiMap;
Expand All @@ -22,9 +23,13 @@ protected void handlePostAsync(RoutingContext event, MultiMap form) throws Excep
if (form.isEmpty()) {
return;
}
SearchMapping searchMapping = HibernateSearchSupplier.searchMapping();
searchMapping.scope(Object.class,
searchMapping.allIndexedEntities().stream()
SearchMapping mapping = HibernateSearchSupplier.searchMapping();
if (mapping == null) {
flashMessage(event, "There aren't any indexed entity types!", FlashScopeUtil.FlashMessageStatus.ERROR);
return;
}
mapping.scope(Object.class,
mapping.allIndexedEntities().stream()
.map(SearchIndexedEntity::jpaName)
.filter(form::contains)
.collect(Collectors.toList()))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.hibernate.search.orm.elasticsearch.runtime.devconsole;

import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;
Expand All @@ -12,7 +13,11 @@
public class HibernateSearchSupplier implements Supplier<List<String>> {
@Override
public List<String> get() {
return searchMapping().allIndexedEntities().stream().map(SearchIndexedEntity::jpaName).sorted()
SearchMapping mapping = searchMapping();
if (mapping == null) {
return Collections.emptyList();
}
return mapping.allIndexedEntities().stream().map(SearchIndexedEntity::jpaName).sorted()
.collect(Collectors.toList());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mutiny-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny</artifactId>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mutiny</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.resteasy.reactive.jackson.deployment.test;

import static org.hamcrest.CoreMatchers.containsString;

import java.util.function.Supplier;

import org.jboss.shrinkwrap.api.ShrinkWrap;
Expand All @@ -27,6 +25,6 @@ public JavaArchive get() {
@Test
public void test() {
RestAssured.with().contentType("application/json").body("{\"name\": \"brie\"}").put("/fromage")
.then().statusCode(500).body(containsString("MismatchedInputException"));
.then().statusCode(400);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;

import org.jboss.resteasy.reactive.common.util.EmptyInputStream;
import org.jboss.resteasy.reactive.server.providers.serialisers.json.AbstractJsonMessageBodyReader;
import org.jboss.resteasy.reactive.server.spi.ServerRequestContext;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;

public class JacksonMessageBodyReader extends AbstractJsonMessageBodyReader {

Expand All @@ -29,13 +31,18 @@ public JacksonMessageBodyReader(ObjectMapper mapper) {
@Override
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
return doReadFrom(type, genericType, entityStream);
throw new IllegalStateException("Should never be called");
}

@Override
public Object readFrom(Class<Object> type, Type genericType, MediaType mediaType, ServerRequestContext context)
throws WebApplicationException, IOException {
return doReadFrom(type, genericType, context.getInputStream());
try {
return doReadFrom(type, genericType, context.getInputStream());
} catch (MismatchedInputException e) {
context.abortWith(Response.status(Response.Status.BAD_REQUEST).build());
return null;
}
}

private Object doReadFrom(Class<Object> type, Type genericType, InputStream entityStream) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,15 @@ private boolean hasAnnotation(MethodInfo method, short paramPosition, DotName an
toScan.add(classInfo);
}
}
//sub resources can also have just a path annotation
//if they are 'intermediate' sub resources
for (AnnotationInstance instance : index.getAnnotations(ResteasyReactiveDotNames.PATH)) {
if (instance.target().kind() == AnnotationTarget.Kind.METHOD) {
MethodInfo method = instance.target().asMethod();
ClassInfo classInfo = method.declaringClass();
toScan.add(classInfo);
}
}
while (!toScan.isEmpty()) {
ClassInfo classInfo = toScan.poll();
if (scannedResources.containsKey(classInfo.name()) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ <h5>REST Resources</h5>
</div>
</div>
{/if}
{#if !endpoint.consumes.isEmpty()}
<div class="row">
<div class="col-1"></div>
<div class="col-1">
Consumes
</div>
<div class="col">
{endpoint.consumes}
</div>
</div>
{/if}
{/for}
<h5>Static Resources</h5>
{#for staticResources in info:staticResourcesInfo}
Expand All @@ -49,4 +60,4 @@ <h5>Additional Endpoints</h5>
</div>
{/for}
{/body}
{/include}
{/include}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Consumes
</div>
<div class="col">
{endpoint.produces}
{endpoint.consumes}
</div>
</div>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ public Optional<RemoteDevClient> getClient() {
return Optional.empty();
}
if (!liveReloadConfig.password.isPresent()) {
log.warn(
throw new RuntimeException(
"Live reload URL set but no password, remote dev requires a password, set quarkus.live-reload.password on both server and client");
return Optional.empty();
}
return Optional.of(new HttpRemoteDevClient(liveReloadConfig.url.get(), liveReloadConfig.password.get()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ static boolean index(Indexer indexer, String className) {

static boolean index(Indexer indexer, String className, ClassLoader classLoader) {
boolean result = false;
if (Types.isPrimitiveClassName(className)) {
return false;
}
try (InputStream stream = classLoader
.getResourceAsStream(className.replace('.', '/') + ".class")) {
if (stream != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ final class Types {

private static final Type OBJECT_TYPE = Type.create(DotNames.OBJECT, Kind.CLASS);

private static final Set<String> PRIMITIVE_CLASS_NAMES = new HashSet<>();

static {
PRIMITIVE_CLASS_NAMES.add("byte");
PRIMITIVE_CLASS_NAMES.add("char");
PRIMITIVE_CLASS_NAMES.add("double");
PRIMITIVE_CLASS_NAMES.add("float");
PRIMITIVE_CLASS_NAMES.add("int");
PRIMITIVE_CLASS_NAMES.add("long");
PRIMITIVE_CLASS_NAMES.add("short");
PRIMITIVE_CLASS_NAMES.add("boolean");
}

// we ban these interfaces because they are new to Java 12 and are used by java.lang.String which
// means that they cannot be included in bytecode if we want to have application built with Java 12+ but targeting Java 8 - 11
// actually run on those older versions
Expand Down Expand Up @@ -405,4 +418,8 @@ static Type box(Primitive primitive) {
}
}

static boolean isPrimitiveClassName(String className) {
return PRIMITIVE_CLASS_NAMES.contains(className);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,19 @@ public void restart(RuntimeResource target, boolean setLocatorTarget) {
this.target = target;
}

/**
* Meant to be used when a error occurred early in processing chain
*/
@Override
public void abortWith(Response response) {
setResult(response);
restart(getAbortHandlerChain());
// this is a valid action after suspend, in which case we must resume
if (isSuspended()) {
resume();
}
}

/**
* Resets the build time serialization assumptions. Called if a filter
* modifies the response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.reactive.common.core.ResteasyReactiveCallbackContext;

public interface ServerRequestContext extends ResteasyReactiveCallbackContext {
Expand All @@ -18,4 +19,6 @@ public interface ServerRequestContext extends ResteasyReactiveCallbackContext {
OutputStream getOrCreateOutputStream();

ResteasyReactiveResourceInfo getResteasyReactiveResourceInfo();

void abortWith(Response response);
}

0 comments on commit 3691945

Please sign in to comment.