You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2018/08/21 13:02:14 UTC

[ambari] branch branch-2.7 updated: AMBARI-24513. Using current timestamp as created_time in case there is no value in users table in this column upon upgrading to 2.7 (#2131)

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

oleewere pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new 542475f  AMBARI-24513. Using current timestamp as created_time in case there is no value in users table in this column upon upgrading to 2.7 (#2131)
542475f is described below

commit 542475f62c1a77997fe38dcc7f5d404891b198e3
Author: Sandor Molnar <sm...@apache.org>
AuthorDate: Tue Aug 21 15:02:11 2018 +0200

    AMBARI-24513. Using current timestamp as created_time in case there is no value in users table in this column upon upgrading to 2.7 (#2131)
---
 .../main/java/org/apache/ambari/server/upgrade/UpgradeCatalog270.java | 2 +-
 .../java/org/apache/ambari/server/upgrade/UpgradeCatalog270Test.java  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog270.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog270.java
index ed5c528..98a549d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog270.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog270.java
@@ -622,7 +622,7 @@ public class UpgradeCatalog270 extends AbstractUpgradeCatalog {
         PreparedStatement pstmt = dbAccessor.getConnection().prepareStatement("SELECT " + USERS_USER_ID_COLUMN + ", " + USERS_CREATE_TIME_COLUMN + " FROM " + USERS_TABLE + " WHERE " + temporaryColumnName + " IS NULL ORDER BY " + USERS_USER_ID_COLUMN);
         ResultSet rs = pstmt.executeQuery()) {
       while (rs.next()) {
-        currentUserCreateTimes.put(rs.getInt(1), rs.getTimestamp(2));
+        currentUserCreateTimes.put(rs.getInt(1), rs.getTimestamp(2) == null ? new Timestamp(System.currentTimeMillis()) : rs.getTimestamp(2));
       }
     }
     return currentUserCreateTimes;
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog270Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog270Test.java
index d91c21f..f9c42b1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog270Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog270Test.java
@@ -658,8 +658,8 @@ public class UpgradeCatalog270Test {
     final ResultSet resultSetMock = niceMock(ResultSet.class);
     expect(preparedStatementMock.executeQuery()).andReturn(resultSetMock);
     expect(resultSetMock.next()).andReturn(Boolean.TRUE).once();
-    expect(resultSetMock.getInt(1)).andReturn(1);
-    expect(resultSetMock.getTimestamp(2)).andReturn(new Timestamp(1l));
+    expect(resultSetMock.getInt(1)).andReturn(1).anyTimes();
+    expect(resultSetMock.getTimestamp(2)).andReturn(new Timestamp(1l)).anyTimes();
     replay(connectionMock, preparedStatementMock, resultSetMock);
 
     expect(dbAccessor.updateTable(eq(USERS_TABLE), eq(temporaryColumnName), eq(1l), anyString())).andReturn(anyInt());