[
https://issues.apache.org/jira/browse/HDFS-16709?focusedWorklogId=796878&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-796878
]
ASF GitHub Bot logged work on HDFS-16709:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 01/Aug/22 13:18
Start Date: 01/Aug/22 13:18
Worklog Time Spent: 10m
Work Description: ZanderXu opened a new pull request, #4667:
URL: https://github.com/apache/hadoop/pull/4667
### Description of PR
When I read some class about Edits of NameNode, I found that there are much
redundant cast inĀ FSEditLogOp.class, I feel that we should remove them.
Such as:
```
static UpdateBlocksOp getInstance(OpInstanceCache cache) {
return (UpdateBlocksOp)cache.get(OP_UPDATE_BLOCKS);
}
```
Because cache.get() have cast the response to T, so we can remove the
redundant cast.
```
@SuppressWarnings("unchecked")
public <T extends FSEditLogOp> T get(FSEditLogOpCodes opCode) {
return useCache ? (T)CACHE.get().get(opCode) : (T)newInstance(opCode);
}
```
Issue Time Tracking
-------------------
Worklog Id: (was: 796878)
Remaining Estimate: 0h
Time Spent: 10m
> Remove redundant cast in FSEditLogOp.class
> ------------------------------------------
>
> Key: HDFS-16709
> URL: https://issues.apache.org/jira/browse/HDFS-16709
> Project: Hadoop HDFS
> Issue Type: Improvement
> Reporter: ZanderXu
> Assignee: ZanderXu
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> When I read some class about Edits of NameNode, I found that there are much
> redundant cast inĀ FSEditLogOp.class, I feel that we should remove them.
> Such as:
> {code:java}
> static UpdateBlocksOp getInstance(OpInstanceCache cache) {
> return (UpdateBlocksOp)cache.get(OP_UPDATE_BLOCKS);
> } {code}
> Because cache.get() have cast the response to T, such as:
> {code:java}
> @SuppressWarnings("unchecked")
> public <T extends FSEditLogOp> T get(FSEditLogOpCodes opCode) {
> return useCache ? (T)CACHE.get().get(opCode) : (T)newInstance(opCode);
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]