Good day!
I am use BuildStatusService in my plugin. Like this (MyClass.java):
private String getFromCommitId(PullRequest pullRequest) { return pullRequest.getFromRef().getLatestChangeset(); } public Iterable<? extends BuildStatus> getBuildStatusList(PullRequest pr) { String changeset = getFromCommitId(pr); return buildStatusService.findAll(changeset).getValues(); }
But NullPointerException is often (not always) in stacktrace:
c.a.s.i.p.DefaultMergeRequestCheckService Merge request check <> of type <> failed. java.lang.NullPointerException: state at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204) ~[guava-10.0.1.jar:na] at com.atlassian.stash.internal.build.InternalBuildStatus.<init>(InternalBuildStatus.java:20) ~[na:na] at com.atlassian.stash.internal.build.BuildStatusServiceImpl$3.apply(BuildStatusServiceImpl.java:98) ~[na:na] at com.atlassian.stash.internal.build.BuildStatusServiceImpl$3.apply(BuildStatusServiceImpl.java:96) ~[na:na] at com.google.common.collect.Iterators$8.next(Iterators.java:782) ~[guava-10.0.1.jar:na] at com.google.common.collect.Lists.newArrayList(Lists.java:139) ~[guava-10.0.1.jar:na] at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:269) ~[guava-10.0.1.jar:na] at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:230) ~[guava-10.0.1.jar:na] at com.atlassian.stash.internal.build.BuildStatusServiceImpl.findAll(BuildStatusServiceImpl.java:64) ~[na:na] at com.sun.proxy.$Proxy1024.findAll(Unknown Source) ~[na:na] at MyClass(MyClass.java:7) ~[na:na]
Community moderators have prevented the ability to post new answers.
HI Dana,
You must have a null value in your AO_CFE8FA_BUILD_STATUS in the 'state' column. That should be impossible. The only public way to add a row is via REST (and thus BuildStatusResource) which checks that 'state' is never null.
Charles
Hello Charles,
mysql> select state, count(csid) from AO_CFE8FA_BUILD_STATUS group by state; +------------+-------------+ | state | count(csid) | +------------+-------------+ | FAILED | 1719 | | INPROGRESS | 268 | | SUCCESSFUL | 5621 | +------------+-------------+ 3 rows in set (0.05 sec)
We check it since we get this NPE. No null in database.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexey,
I'm assuming you've looked at AoBuildStatusDao. I can't see any other way that you would get an NPE. Are you sure that query will group by null? How many total rows are there in that table if you don't group by?
Cheers,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm. Damn, it looks like GROUP BY does group on nulls.
Sorry Alexey/Dana, I've never seen that error before and I can offer no explanation as to why it might be happening.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexy,
At this point I'm afraid the only thing we can do is raise a support ticket and go from there.
We should be able to send you an updated version of the build-integration plugin with some extra debugging that will tell us what row is broken and what the value of state is.
Cheers,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Charles, can it be one of follow:
1. jar hell in dependencies (but build-integration is part of stash and we use provided only)?
2. We also invoke add(BuildStatus) with own fake implementation, to add INPOGRESS build until CI server really starts it. Can it affect?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexey,
Can you show us the code that adds the build status? I'm assuming this, or something like it, is the cause of the problem. It's less likely to be jar hell.
Cheers,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There was a problem with authorization. Because MergeCheck turns on "READ-ONLY" by "Transactional" annotation& So we have decided to add status in parallel therad with SecurityService. Like this:
Future<String> changesetF = executorService.submit(new Callable<String>() { @Override public String call() { try { String authMessage = "Adding IN_PROGRESS status for queued build"; String user = "bot-user"; String changeset = securityService.doAsUser( authMessage, user, new OperationGrantPermission<String>( securityService, new UncheckedOperation<String>() { @Override public String perform() { try { String commit = getBuildChangeset(pullRequest); buildStatusService .add(commit, new TeamcityIntegrationBuildStatus(buildId)); return commit; } catch (Exception e) { throw new RuntimeException(e); } } }, authMessage, Sets.newHashSet(Permission.REPO_WRITE, Permission.LICENSED_USER))); return changeset; } catch (Throwable e) { log.error("Error while storing build status", e); throw new RuntimeException(e); } } });
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
public class TeamcityIntegrationBuildStatus implements BuildStatus { ... @Nonnull @Override public State getState() { return State.INPROGRESS; } ... }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys,
Ok I have nothing. I can see no conceiveable way that State would be null. My suggestion, given that you compile from source, is to put some debugging into the offending code and figure out what database row is broken. I'm sorry I can't help any more than that. :(
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.