Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Can not find variable 3 in stack #645

Closed
dsp0549 opened this issue Dec 14, 2022 · 8 comments
Closed

[BUG] Can not find variable 3 in stack #645

dsp0549 opened this issue Dec 14, 2022 · 8 comments
Assignees

Comments

@dsp0549
Copy link

dsp0549 commented Dec 14, 2022

JobRunr Version

4.0.10

JDK Version

1.8.0_342

Your SQL / NoSQL database

MySQL 8

What happened?

we recently changed the signature of an enqueue task, and are now receiving shouldNotHappenException claiming "Can not find variable 3 in stack"

we have rebooted the server and the issue continues to occur

How to reproduce?

original code:

    HubspotManager hm = new HubspotManager();
    JobRunrConfig.enqueue(() -> hm.updateContactAddress(updatedAddress.getCustomerId(), updatedAddress));

new code:

    HubspotManager hm = new HubspotManager();
    long customerId = updatedAddress.getCustomerId();
    JobRunrConfig.enqueue(() -> hm.updateContactAddress(customerId, updatedAddress));

for reference, JobRunrConfig utility class

    public static JobId enqueue(JobLambda job) {
        JobId jobId = BackgroundJob.enqueue(job);
        enqueuedJobs.add(jobId);
        return jobId;
    }

Relevant log output

ERROR: Update address failed org.jobrunr.JobRunrException: JobRunr encountered a problematic exception. Please create a bug report (if possible, provide the code to reproduce this and the stacktrace)
	at org.jobrunr.JobRunrException.shouldNotHappenException(JobRunrException.java:33)
	at org.jobrunr.jobs.details.JobDetailsBuilder.getLocalVariable(JobDetailsBuilder.java:50)
	at org.jobrunr.jobs.details.instructions.VisitLocalVariableInstruction.invokeInstruction(VisitLocalVariableInstruction.java:20)
	at org.jobrunr.jobs.details.instructions.AbstractJVMInstruction.invokeInstructionAndPushOnStack(AbstractJVMInstruction.java:18)
	at org.jobrunr.jobs.details.JobDetailsBuilder.invokeInstructions(JobDetailsBuilder.java:92)
	at org.jobrunr.jobs.details.JobDetailsBuilder.getJobDetails(JobDetailsBuilder.java:70)
	at org.jobrunr.jobs.details.AbstractJobDetailsFinder.getJobDetails(AbstractJobDetailsFinder.java:84)
	at org.jobrunr.jobs.details.JavaJobDetailsFinder.getJobDetails(JavaJobDetailsFinder.java:10)
	at org.jobrunr.jobs.details.JobDetailsAsmGenerator.toJobDetails(JobDetailsAsmGenerator.java:18)
	at org.jobrunr.jobs.details.CachingJobDetailsGenerator$CacheableJobDetails.getJobDetails(CachingJobDetailsGenerator.java:70)
	at org.jobrunr.jobs.details.CachingJobDetailsGenerator.toJobDetails(CachingJobDetailsGenerator.java:36)
	at org.jobrunr.scheduling.JobScheduler.enqueue(JobScheduler.java:92)
	at org.jobrunr.scheduling.JobScheduler.enqueue(JobScheduler.java:74)
	at org.jobrunr.scheduling.BackgroundJob.enqueue(BackgroundJob.java:39)
	at com.smartac.userapp.util.JobRunrConfig.enqueue(JobRunrConfig.java:199)
	at com.smartac.userapp.manager.AddressManager.updateAddress(AddressManager.java:218)
	at com.smartac.userapp.rest.impl.AddressServiceImpl.updateAddress(AddressServiceImpl.java:70)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:138)
	at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:546)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:435)
	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:396)
	at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:398)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:365)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:338)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135)
	at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215)
	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:245)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:61)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:196)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:367)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:639)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:882)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1691)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:750)

Caused by: java.lang.IllegalStateException: Can not find variable 3 in stack
	... 61 more
@rdehuyss
Copy link
Contributor

I'm unable to reproduce this (both with the latest version and the v4.0.10).

I tried with the test below:

    @Test
    void testViaWrapper() {
        TestService.Work myWork = new TestService.Work(5, "my string", UUID.randomUUID());
        testWithMethod(myWork);
    }

    void testWithMethod(TestService.Work work) {
        TestService newTestService = new TestService();
        int workCount = work.getWorkCount();
        JobId jobId = JobRunrWrapper.enqueue(() -> newTestService.doWork(workCount, work));
        await().atMost(30, SECONDS).until(() -> storageProvider.getJobById(jobId).hasState(SUCCEEDED));
    }

    public static class JobRunrWrapper {
        public static JobId enqueue(JobLambda job) {
            JobId jobId = BackgroundJob.enqueue(job);
            System.out.println("Doing something with the JobId: " + jobId);
            return jobId;
        }
    }

Please create a Github repo reproducing this with the latest JobRunr version and then reopen this issue.

@vergil-zhao
Copy link

I met the same problem in Kotlin. And this problem won't appear in tests, it only appear in running by bootRun.

When the lambda captures a custom class/interface like the one below, it will work:

jobScheduler.enqueue(null, {
    fulfillFreightClientOrderJob.fulfillFreightClientOrder(
        clientOrder.id!!, // interface IClientOrder
        referenceFid,
    )
})

But if only capture Long/String, it will fail with the exception Can not find variable 3 in stack:

jobScheduler.enqueue(null, {
    fulfillFreightClientOrderJob.fulfillFreightClientOrder(
        clientOrderId, // Long
        referenceFid, // String
    )
})

@rdehuyss
Copy link
Contributor

rdehuyss commented Aug 16, 2023

I'm still unable to reproduce it:

    @Test
    void testIssue645() {
        TestService.GithubIssue645 githubIssue645 = new TestService.GithubIssue645();
        JobId jobId = BackgroundJob.enqueue(() -> testService.doWorkForIssue645(githubIssue645.getId(), githubIssue645));
        await().atMost(30, SECONDS).until(() -> storageProvider.getJobById(jobId).hasState(SUCCEEDED));
    }

where GithubIssue645

    public static class GithubIssue645 {
        private Long id;

        public GithubIssue645() {
            this.id = 2L;
        }

        public Long getId() {
            return id;
        }
    }

And TestService:

    public void doWorkForIssue645(Long id, GithubIssue645 someObject) {
        System.out.println("Doing work for github issue 645 " + id.toString() + "; " + someObject);
    }

@vergilchoi : could you setup a reproducible Github Repo?

@vergil-zhao
Copy link

vergil-zhao commented Aug 24, 2023

Hi @rdehuyss , I have created a repo that tries to help with reproducing the problem. Please check the repo. Follow the readme then should see the same problem.

@vergil-zhao
Copy link

Hi @rdehuyss , just wondering if you have checked the repo and figured out the problem?

@rdehuyss
Copy link
Contributor

rdehuyss commented Sep 8, 2023

Hi @vergilchoi - I'm really sorry but not yet. Some things came up but please know that it is definitely still on my todo list.

@rdehuyss
Copy link
Contributor

Thx for the reproducible scenario, I was able to reproduce it. Looking into it.

rdehuyss added a commit that referenced this issue Sep 15, 2023
@rdehuyss
Copy link
Contributor

The cause was found and a fix was implemented.

Thanks @vergilchoi to provide a working reproducible scenario - these kind of things really help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants