[ 
https://issues.apache.org/jira/browse/SENTRY-2141?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kalyan Kalvagadda updated SENTRY-2141:
--------------------------------------
    Fix Version/s: 2.2.0

> Sentry Privilege TimeStamp is not converted to grantTime in HivePrivilegeInfo 
> correctly
> ---------------------------------------------------------------------------------------
>
>                 Key: SENTRY-2141
>                 URL: https://issues.apache.org/jira/browse/SENTRY-2141
>             Project: Sentry
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.1.0
>            Reporter: Na Li
>            Assignee: Na Li
>            Priority: Major
>             Fix For: 2.2.0
>
>         Attachments: SENTRY-2141.001.patch, SENTRY-2141.002.patch, 
> SENTRY-2141.003.patch
>
>
> since hive is using second as time unit and the variable holding the time is 
> "int", sentry should convert the time from millisecond to second and cast to 
> int. Previous code just cast the long value as time in milliseconds to int as 
> time in seconds, which runs into overflows (because a Long can store a wider 
> range than an Integer), and changes the meaning of the value. 
> Correct behavior:
> {code}
> int hiveCreateTime = (int)TimeUnit.SECONDS.convert(tPrivilege.getCreateTime(),
> TimeUnit.MILLISECONDS);
> return new HivePrivilegeInfo(principal, hivePrivilege, hivePrivilegeObject, 
> grantor,
> grantOption, hiveCreateTime);
> {code}
> Wrong behavior:
> {code}
> (int) tPrivilege.getCreateTime()
> {code}
> The original code just cast the timestamp from long to int without converting 
> milliseconds to seconds. Therefore, the timestamp value is wrong when 
> retrieving the privilege from hive.
> The solution is to convert the time correctly.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to