My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 3005: ClassCastException in MergeSorter
2 people starred this issue and may be notified of changes. Back to list
Status:  Invalid
Owner:  ----
Closed:  Feb 2015


Sign in to add a comment
 
Reported by andreas....@gmail.com, Nov 5, 2014
************************************************************
***** NOTE: THIS BUG TRACKER IS FOR GERRIT CODE REVIEW *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, INTERNAL *****
***** ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.    *****
***** THOSE ISSUE BELONG IN DIFFERENT ISSUE TRACKERS!  *****
************************************************************

Affected Version: v2.9.1-12-g80ad102 (and probably since forever)

What steps will reproduce the problem?
1. Create a custom plugin. I can't see how it would cause this error but still, it probably does.
2. Create two commits from the same branch, push both to gerrit for review and submit them in reverse order.
3. Get "pending merge" on both of them, in the error log find a ClassCastException and a stacktrace (added below)
4. Wait some, press submit some more, eventually the merge will happen.

What is the expected output? What do you see instead?
I expect that the second commit gets merged as soon as the first one does.


Please provide any additional information below.

I realize this bug report is kinda of weird but perhaps it makes sense to you.

I've found that on line 65 if MergeSorter object c is sometimes just a RevCommit but not a CodeReviewCommit, this is what causes the exception.

Here is the stack trace

[2014-11-05 11:44:16,444] ERROR com.google.gerrit.server.git.ChangeMergeQueue : Merge attempt for xbn,refs/heads/master failed
java.lang.ClassCastException: org.eclipse.jgit.revwalk.RevCommit cannot be cast to com.google.gerrit.server.git.CodeReviewCommit
        at com.google.gerrit.server.git.MergeSorter.sort(MergeSorter.java:65)
        at com.google.gerrit.server.git.MergeUtil.reduceToMinimalMerge(MergeUtil.java:155)
        at com.google.gerrit.server.git.strategy.MergeIfNecessary._run(MergeIfNecessary.java:32)
        at com.google.gerrit.server.git.strategy.SubmitStrategy.run(SubmitStrategy.java:115)
        at com.google.gerrit.server.git.MergeOp.preMerge(MergeOp.java:363)
        at com.google.gerrit.server.git.MergeOp.merge(MergeOp.java:251)
        at com.google.gerrit.server.git.ChangeMergeQueue$2.call(ChangeMergeQueue.java:210)
        at com.google.gerrit.server.git.ChangeMergeQueue$2.call(ChangeMergeQueue.java:207)
        at com.google.gerrit.server.util.RequestScopePropagator$5.call(RequestScopePropagator.java:222)
        at com.google.gerrit.server.util.RequestScopePropagator$4.call(RequestScopePropagator.java:201)
        at com.google.gerrit.server.git.PerThreadRequestScope$Propagator$1.call(PerThreadRequestScope.java:75)
        at com.google.gerrit.server.git.ChangeMergeQueue.mergeImpl(ChangeMergeQueue.java:207)
        at com.google.gerrit.server.git.ChangeMergeQueue.merge(ChangeMergeQueue.java:125)
        at com.google.gerrit.server.change.Submit.apply(Submit.java:159)
        at com.google.gerrit.server.change.Submit.apply(Submit.java:72)
        at com.google.gerrit.httpd.restapi.RestApiServlet.service(RestApiServlet.java:303)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:278)
        at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:268)
        at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:180)
        at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:93)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:85)
        at com.google.gerrit.pgm.http.jetty.GetUserFilter.doFilter(GetUserFilter.java:76)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.gwtexpui.server.CacheControlFilter.doFilter(CacheControlFilter.java:70)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.gerrit.httpd.RunAsFilter.doFilter(RunAsFilter.java:113)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.gerrit.httpd.AllRequestFilter$FilterProxy$1.doFilter(AllRequestFilter.java:64)
        at com.google.gerrit.httpd.AllRequestFilter$FilterProxy.doFilter(AllRequestFilter.java:57)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.gerrit.httpd.RequestContextFilter.doFilter(RequestContextFilter.java:75)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120)
        at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:132)
        at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:129)
        at com.google.inject.servlet.GuiceFilter$Context.call(GuiceFilter.java:206)
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:129)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1539)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:524)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:219)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1110)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:453)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1044)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:92)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.Server.handle(Server.java:459)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:280)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:229)
        at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)
        at java.lang.Thread.run(Thread.java:745)

Nov 8, 2014
#4 andreas....@gmail.com
It's ok to close this bug, I found the reason for it.

And while I still there is a bug I no longer thing this is an accurate description of it.
Nov 16, 2014
Project Member #5 david.pu...@sonymobile.com
> I found the reason for it

And the reason was...?

Nov 17, 2014
#6 andreas....@gmail.com
When entering MergeValidationListener#onPreMerge you are given a commit that should be validated. I needed the tree of it's parent which I thought was okey to get with commit.getParent(0).getTree(). 

As it turns out, that commit isn't isolated enough from outside the validator and as a side effect of doing that the parent will be populated and that destroys the flow outside. I changed it to getting the parent from a RevWalk by it's id.

I do consider this a bug though, nothing inside the validator should be able to cause an entirely different flow on the outside.

I also think that the validation is done too early in the process. In my opinion the merges should be sorted first and then, just as one of them are about to be merged into the repository the validation should happen. 

As it is now, two merges can be validated separately, then sorted and merged. The validator might not allow the second one to be merged after the first as part of it's validation strategy.
Feb 17, 2015
Project Member #7 edwin.ke...@gmail.com
(No comment was entered for this change.)
Status: Invalid
Sign in to add a comment

Powered by Google Project Hosting