You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2018/10/11 11:28:28 UTC

[ignite-teamcity-bot] branch master updated: Fix for version error 500 during activation

This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git


The following commit(s) were added to refs/heads/master by this push:
     new 1d4a67f  Fix for version error 500 during activation
1d4a67f is described below

commit 1d4a67f11eb592a750e3403ca73f5dcee61e7624
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Thu Oct 11 14:28:26 2018 +0300

    Fix for version error 500 during activation
---
 .../ignite/ci/tcbot/TcBotGeneralService.java       | 50 ++++++++++++++++++++++
 .../ignite/ci/web/rest/GetTrackedBranches.java     | 13 +-----
 2 files changed, 52 insertions(+), 11 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/TcBotGeneralService.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/TcBotGeneralService.java
new file mode 100644
index 0000000..ae6e7b7
--- /dev/null
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/TcBotGeneralService.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.ci.tcbot;
+
+import javax.inject.Inject;
+import javax.inject.Provider;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.ci.web.model.Version;
+import org.apache.ignite.lang.IgniteProductVersion;
+
+/**
+ *
+ */
+public class TcBotGeneralService {
+    @Inject Provider<Ignite> igniteProvider;
+    /**
+     *
+     */
+    public Version version() {
+        Version ver = new Version();
+
+        try {
+            IgniteProductVersion ignProdVer = igniteProvider.get().version();
+
+            ver.ignVer = ignProdVer.major() + "." + ignProdVer.minor() + "." + ignProdVer.maintenance();
+
+            ver.ignVerFull = ignProdVer.toString();
+        }
+        catch (Exception ignored) {
+            //probably service is starting
+            ver.ignVer = "?";
+        }
+
+        return ver;
+    }
+}
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetTrackedBranches.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetTrackedBranches.java
index 7febe0e..3bff0ac 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetTrackedBranches.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetTrackedBranches.java
@@ -28,13 +28,12 @@ import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
-import org.apache.ignite.Ignite;
 import org.apache.ignite.ci.HelperConfig;
 import org.apache.ignite.ci.conf.ChainAtServer;
+import org.apache.ignite.ci.tcbot.TcBotGeneralService;
 import org.apache.ignite.ci.user.ICredentialsProv;
 import org.apache.ignite.ci.web.CtxListener;
 import org.apache.ignite.ci.web.model.Version;
-import org.apache.ignite.lang.IgniteProductVersion;
 
 /**
  * Service for returning tracked branches, servers, and the bot version.
@@ -54,15 +53,7 @@ public class GetTrackedBranches {
     @Path("version")
     @PermitAll
     public Version version() {
-        Version ver = new Version();
-
-        IgniteProductVersion ignProdVer = CtxListener.getInjector(ctx).getInstance(Ignite.class).version();
-
-        ver.ignVer = ignProdVer.major() + "." + ignProdVer.minor() + "." + ignProdVer.maintenance();
-
-        ver.ignVerFull = ignProdVer.toString();
-
-        return ver;
+        return CtxListener.getInjector(ctx).getInstance(TcBotGeneralService.class).version();
     }
 
     @GET