Skip to content

Commit

Permalink
fix: ignore abstract AppShellConfigurators (#19706) (#19708)
Browse files Browse the repository at this point in the history
* fix: ignore abstract AppShellConfigurators

* Also test that interface is ignored

* Make annotations Inherited; fix test

* Revert @PageTitle change

* Remove import as well

Co-authored-by: Teppo Kurki <teppo.kurki@vaadin.com>
  • Loading branch information
vaadin-bot and tepi authored Jul 22, 2024
1 parent 7887922 commit d00357a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand All @@ -32,6 +33,7 @@
@Target(ElementType.TYPE)
@Documented
@Repeatable(Inline.Container.class)
@Inherited
public @interface Inline {
/**
* File content wrapping enum.
Expand Down Expand Up @@ -82,6 +84,7 @@ enum Position {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@Inherited
@interface Container {

/**
Expand Down
2 changes: 2 additions & 0 deletions flow-server/src/main/java/com/vaadin/flow/server/PWA.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.vaadin.flow.server;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
Expand Down Expand Up @@ -55,6 +56,7 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface PWA {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -104,6 +105,7 @@ public static void init(Set<Class<?>> classes, VaadinContext context) {
.lookup(AppShellPredicate.class);

classes.stream()
.filter(clazz -> !Modifier.isAbstract(clazz.getModifiers()))
// sort classes by putting the app shell in first position
.sorted((a, b) -> predicate.isShell(a) ? -1
: predicate.isShell(b) ? 1 : 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@
@NotThreadSafe
public class VaadinAppShellInitializerTest {

public interface InterfaceAppShellWithoutAnnotations
extends AppShellConfigurator {
}

public static abstract class AbstractAppShellWithoutAnnotations
implements InterfaceAppShellWithoutAnnotations {
}

public static class MyAppShellWithoutAnnotations
implements AppShellConfigurator {
extends AbstractAppShellWithoutAnnotations {
}

@Meta(name = "foo", content = "bar")
Expand Down Expand Up @@ -399,6 +407,15 @@ public void should_throw_when_multipleAppShell() throws Exception {
initializer.process(classes, servletContext);
}

@Test
public void should_not_throw_when_interface_and_abstract_and_concrete_AppShell()
throws Exception {
classes.add(InterfaceAppShellWithoutAnnotations.class);
classes.add(AbstractAppShellWithoutAnnotations.class);
classes.add(MyAppShellWithoutAnnotations.class);
initializer.process(classes, servletContext);
}

@Test
public void should_not_throw_when_appShellAnnotationsAreAllowed_and_offendingClass()
throws Exception {
Expand Down

0 comments on commit d00357a

Please sign in to comment.