BackgroundFunctionExecutor.java failes to detect type when sub-classed
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 38/100
Rechercherichtung
Beginne in BackgroundFunctionExecutor.java bei Zeile 140 und untersuche backgroundFunctionTypeArgument. Reproduziere die in der Aufgabe beschriebene Hierarchie von MyExtendedBackgroundFunction und MyFunctionHandler und überprüfe anschließend, dass der Executor MyReturnType erkennt und dabei das Verhalten für direkt implementierte BackgroundFunction-Typen beibehält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Error Condition
Exception in thread "main" java.lang.RuntimeException: Could not determine the payload type for BackgroundFunction of type com.example.MyFunctionHandler; must implement BackgroundFunction for some T at com.google.cloud.functions.invoker.BackgroundFunctionExecutor.forClass(BackgroundFunctionExecutor.java:140) at com.google.cloud.functions.invoker.BackgroundFunctionExecutor.forClass(BackgroundFunctionExecutor.java:113) at com.google.cloud.functions.invoker.runner.Invoker.startServer(Invoker.java:256) at com.google.cloud.functions.invoker.runner.Invoker.main(Invoker.java:127)
Occurs when BackgroundFunction<T> is subclassed:
public abstract class MyExtendedBackgroundFunction<T> implements BackgroundFunction<T>
and
public class MyFunctionHandler extends MyExtendedBackgroundFunction<MyReturnType>
In the class mentioned, the following function fails to detect sub-classed BackgroundFunction type:
static Optional<Type> backgroundFunctionTypeArgument(Class<? extends BackgroundFunction<?>> functionClass) {
// If this is BackgroundFunction<Foo> then the user must have implemented a method
// accept(Foo, Context), so we look for that method and return the type of its first argument.
// We must be careful because the compiler will also have added a synthetic method
// accept(Object, Context).
return Arrays.stream(functionClass.getMethods())
.filter(m -> m.getName().equals("accept") && m.getParameterCount() == 2 && m.getParameterTypes()[1] == Context.class && m.getParameterTypes()[0] != Object.class)
.map(m -> m.getGenericParameterTypes()[0])
.findFirst();
}
This fails for described MyFunctionHandler.
The intent is to add common boilerplate handling for a couple of functions which is common to all. A separate abstract function is employed, but the function fails to load because the type is not determined.
Temporary workaround is to re-implement accept() with the type in the sub-classed object with the type, but is inelegant.
- Vorherrschende Sprache
- Java
- Sterne
- 155
- Forks
- 64
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus GoogleCloudPlatform/functions-framework-java
-
enhancement P2
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
-
Incompatible conversion from Pub/Sub emulator to CloudEvent for `CloudEventsFunction`Evtl. wieder frei @taeold hat das vor 222 Tagen übernommen, und es ist kein Pull Request offen. Offenenhancement
GoogleCloudPlatform/functions-framework-java#375 · 1 Kommentar · 1 Reaktion · 1 zugewiesene Person ·
-
enhancement P2
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 30/100
GoogleCloudPlatform/functions-framework-java#372 · 1 Kommentar ·
-
Add support for auto-reload in run goal of function-maven-pluginEvtl. wieder frei @janell-chen hat das vor 1010 Tagen übernommen, und es ist kein Pull Request offen. Offenenhancement P3
GoogleCloudPlatform/functions-framework-java#261 · 1 zugewiesene Person ·
-
How to run `google/fhir-data-pipes/pipelines/batch` uber JAR in Google Cloud Functions locally?OffenP3 question
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
GoogleCloudPlatform/functions-framework-java#254 · 1 Kommentar ·
Alle Issues in GoogleCloudPlatform/functions-framework-java
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
floci-io/floci#5425 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
objectionary/eo-graphs#80 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
objectionary/jucs#141 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
-
bug good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
repowise-dev/repowise#3335 ·
Maintainer antworten meist innerhalb von 1 Tag