You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "gaobinlong (via GitHub)" <gi...@apache.org> on 2026/03/25 06:44:59 UTC
[PR] Replace explicit type conversion with instance pattern variable in core module [lucene]
gaobinlong opened a new pull request, #15874:
URL: https://github.com/apache/lucene/pull/15874
### Description
As a follow-up of https://github.com/apache/lucene/pull/15837, replace all explicit type conversions with instanceof pattern variable in core module, using the modern style aims to improve the code readability and reduces potential ClassCastException risks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Replace explicit type conversion with instance pattern variable in core module [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on code in PR #15874:
URL: https://github.com/apache/lucene/pull/15874#discussion_r3020537575
##########
lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/BytesTermAttributeImpl.java:
##########
@@ -70,8 +70,9 @@ public void reflectWith(AttributeReflector reflector) {
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof BytesTermAttributeImpl)) return false;
- BytesTermAttributeImpl that = (BytesTermAttributeImpl) o;
+ if (!(o instanceof BytesTermAttributeImpl that)) {
Review Comment:
Correction - we do run unused variable analysis (as part of ecj run); that variable is used here but below what I could see in the diff.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Replace explicit type conversion with instance pattern variable in core module [lucene]
Posted by "gaobinlong (via GitHub)" <gi...@apache.org>.
gaobinlong commented on PR #15874:
URL: https://github.com/apache/lucene/pull/15874#issuecomment-4170199215
Thanks @dweiss , mind taking a look at the similar PRs? https://github.com/apache/lucene/pull/15889, https://github.com/apache/lucene/pull/15842, https://github.com/apache/lucene/pull/15837, https://github.com/apache/lucene/pull/15834.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Replace explicit type conversion with instance pattern variable in core module [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on code in PR #15874:
URL: https://github.com/apache/lucene/pull/15874#discussion_r3020381563
##########
lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/BytesTermAttributeImpl.java:
##########
@@ -70,8 +70,9 @@ public void reflectWith(AttributeReflector reflector) {
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof BytesTermAttributeImpl)) return false;
- BytesTermAttributeImpl that = (BytesTermAttributeImpl) o;
+ if (!(o instanceof BytesTermAttributeImpl that)) {
Review Comment:
Ok, we don't run unused variable checks; I swear we did once. Maybe we should restore it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Replace explicit type conversion with instance pattern variable in core module [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss merged PR #15874:
URL: https://github.com/apache/lucene/pull/15874
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Replace explicit type conversion with instance pattern variable in core module [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on code in PR #15874:
URL: https://github.com/apache/lucene/pull/15874#discussion_r3019984469
##########
lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/BytesTermAttributeImpl.java:
##########
@@ -70,8 +70,9 @@ public void reflectWith(AttributeReflector reflector) {
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof BytesTermAttributeImpl)) return false;
- BytesTermAttributeImpl that = (BytesTermAttributeImpl) o;
+ if (!(o instanceof BytesTermAttributeImpl that)) {
Review Comment:
I don't think the variable is needed in this case. I'm not sure why the checks don't complain about unused variable here - they should.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org