BackgroundFunctionExecutor.java failes to detect type when sub-classed
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 38/100
Piste de recherche
Commencez dans BackgroundFunctionExecutor.java à la ligne 140 et examinez backgroundFunctionTypeArgument. Reproduisez la hiérarchie MyExtendedBackgroundFunction et MyFunctionHandler décrite dans l’issue, puis vérifiez que l’exécuteur détecte MyReturnType tout en préservant le comportement pour les types BackgroundFunction implémentés directement.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Java
- Étoiles
- 154
- Forks
- 63
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de GoogleCloudPlatform/functions-framework-java
-
enhancement P2
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
-
Incompatible conversion from Pub/Sub emulator to CloudEvent for `CloudEventsFunction`Peut-être à nouveau libre @taeold l’a pris il y a 207 jours, et aucune pull request n’est ouverte. Ouverteenhancement
GoogleCloudPlatform/functions-framework-java#375 · 1 commentaire · 1 réaction · 1 personne assignée ·
-
enhancement P2
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 30/100
GoogleCloudPlatform/functions-framework-java#372 · 1 commentaire ·
-
Add support for auto-reload in run goal of function-maven-pluginPeut-être à nouveau libre @janell-chen l’a pris il y a 995 jours, et aucune pull request n’est ouverte. Ouverteenhancement P3
GoogleCloudPlatform/functions-framework-java#261 · 1 personne assignée ·
-
How to run `google/fhir-data-pipes/pipelines/batch` uber JAR in Google Cloud Functions locally?OuverteP3 question
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
GoogleCloudPlatform/functions-framework-java#254 · 1 commentaire ·
Toutes les issues de GoogleCloudPlatform/functions-framework-java
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
ci-failure-cause test-failure
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
nextcloud/notes-android#3367 ·
Les mainteneurs répondent en général sous 1 jour
-
:wave: team-triage a:chore in:isolated-projects in:kotlin-dsl
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour