[jira] [Updated] (CASSANDRA-14385) Fix Some Potential NPE
[ https://issues.apache.org/jira/browse/CASSANDRA-14385?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Aleksei Zotov updated CASSANDRA-14385: -- Resolution: Incomplete Status: Resolved (was: Open) [~xiaoheipangzi] We got no reply from your side, so I'm closing this ticket for now. Please, do not hesitate to re-open it if you feel that the proposed changes are still actual. Thank you for the desire to improve the project! We look forward to getting more contributions. > Fix Some Potential NPE > --- > > Key: CASSANDRA-14385 > URL: https://issues.apache.org/jira/browse/CASSANDRA-14385 > Project: Cassandra > Issue Type: Bug > Components: Feature/Materialized Views >Reporter: lujie >Priority: Normal > Attachments: CA-14385_1.patch > > Time Spent: 10m > Remaining Estimate: 0h > > We have developed a static analysis tool > [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential > NPE. Our analysis shows that some callees may return null in corner case(e.g. > node crash , IO exception), some of their callers have _!=null_ check but > some do not have. In this issue we post a patch which can add !=null based > on existed !=null check. For example: > Calle Schema#getView may return null: > {code:java} > public ViewMetadata getView(String keyspaceName, String viewName) > { > assert keyspaceName != null; > KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); > return (ksm == null) ? null : ksm.views.getNullable(viewName);//may > return null > } > {code} > it have 4 callers, 3 of them have !=null check, like its caller > MigrationManager#announceViewDrop have !=null check() > {code:java} > public static void announceViewDrop(String ksName, String viewName, boolean > announceLocally) throws ConfigurationException > { >ViewMetadata view = Schema.instance.getView(ksName, viewName); > if (view == null)//null pointer checker > throw new ConfigurationException(String.format("Cannot drop non > existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); >KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); >logger.info("Drop table '{}/{}'", view.keyspace, view.name); >announce(SchemaKeyspace.makeDropViewMutation(ksm, view, > FBUtilities.timestampMicros()), announceLocally); > } > {code} > but caller MigrationManager#announceMigration does not have > We add !=null check based on MigrationManager#announceViewDrop: > {code:java} > if (current == null) > throw new InvalidRequestException("There is no materialized view in > keyspace " + keyspace()); > {code} > But due to we are not very familiar with CASSANDRA, hope some expert can > review it. > Thanks > -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Updated] (CASSANDRA-14385) Fix Some Potential NPE
[ https://issues.apache.org/jira/browse/CASSANDRA-14385?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Aleksei Zotov updated CASSANDRA-14385: -- Status: Open (was: Patch Available) > Fix Some Potential NPE > --- > > Key: CASSANDRA-14385 > URL: https://issues.apache.org/jira/browse/CASSANDRA-14385 > Project: Cassandra > Issue Type: Bug > Components: Feature/Materialized Views >Reporter: lujie >Priority: Normal > Attachments: CA-14385_1.patch > > Time Spent: 10m > Remaining Estimate: 0h > > We have developed a static analysis tool > [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential > NPE. Our analysis shows that some callees may return null in corner case(e.g. > node crash , IO exception), some of their callers have _!=null_ check but > some do not have. In this issue we post a patch which can add !=null based > on existed !=null check. For example: > Calle Schema#getView may return null: > {code:java} > public ViewMetadata getView(String keyspaceName, String viewName) > { > assert keyspaceName != null; > KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); > return (ksm == null) ? null : ksm.views.getNullable(viewName);//may > return null > } > {code} > it have 4 callers, 3 of them have !=null check, like its caller > MigrationManager#announceViewDrop have !=null check() > {code:java} > public static void announceViewDrop(String ksName, String viewName, boolean > announceLocally) throws ConfigurationException > { >ViewMetadata view = Schema.instance.getView(ksName, viewName); > if (view == null)//null pointer checker > throw new ConfigurationException(String.format("Cannot drop non > existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); >KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); >logger.info("Drop table '{}/{}'", view.keyspace, view.name); >announce(SchemaKeyspace.makeDropViewMutation(ksm, view, > FBUtilities.timestampMicros()), announceLocally); > } > {code} > but caller MigrationManager#announceMigration does not have > We add !=null check based on MigrationManager#announceViewDrop: > {code:java} > if (current == null) > throw new InvalidRequestException("There is no materialized view in > keyspace " + keyspace()); > {code} > But due to we are not very familiar with CASSANDRA, hope some expert can > review it. > Thanks > -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Updated] (CASSANDRA-14385) Fix Some Potential NPE
[ https://issues.apache.org/jira/browse/CASSANDRA-14385?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] C. Scott Andreas updated CASSANDRA-14385: - Component/s: Materialized Views > Fix Some Potential NPE > --- > > Key: CASSANDRA-14385 > URL: https://issues.apache.org/jira/browse/CASSANDRA-14385 > Project: Cassandra > Issue Type: Bug > Components: Materialized Views >Reporter: lujie >Priority: Major > Attachments: CA-14385_1.patch > > > We have developed a static analysis tool > [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential > NPE. Our analysis shows that some callees may return null in corner case(e.g. > node crash , IO exception), some of their callers have _!=null_ check but > some do not have. In this issue we post a patch which can add !=null based > on existed !=null check. For example: > Calle Schema#getView may return null: > {code:java} > public ViewMetadata getView(String keyspaceName, String viewName) > { > assert keyspaceName != null; > KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); > return (ksm == null) ? null : ksm.views.getNullable(viewName);//may > return null > } > {code} > it have 4 callers, 3 of them have !=null check, like its caller > MigrationManager#announceViewDrop have !=null check() > {code:java} > public static void announceViewDrop(String ksName, String viewName, boolean > announceLocally) throws ConfigurationException > { >ViewMetadata view = Schema.instance.getView(ksName, viewName); > if (view == null)//null pointer checker > throw new ConfigurationException(String.format("Cannot drop non > existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); >KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); >logger.info("Drop table '{}/{}'", view.keyspace, view.name); >announce(SchemaKeyspace.makeDropViewMutation(ksm, view, > FBUtilities.timestampMicros()), announceLocally); > } > {code} > but caller MigrationManager#announceMigration does not have > We add !=null check based on MigrationManager#announceViewDrop: > {code:java} > if (current == null) > throw new InvalidRequestException("There is no materialized view in > keyspace " + keyspace()); > {code} > But due to we are not very familiar with CASSANDRA, hope some expert can > review it. > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Updated] (CASSANDRA-14385) Fix Some Potential NPE
[ https://issues.apache.org/jira/browse/CASSANDRA-14385?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] lujie updated CASSANDRA-14385: -- Status: Patch Available (was: Open) > Fix Some Potential NPE > --- > > Key: CASSANDRA-14385 > URL: https://issues.apache.org/jira/browse/CASSANDRA-14385 > Project: Cassandra > Issue Type: Bug >Reporter: lujie >Priority: Major > Attachments: CA-14385_1.patch > > > We have developed a static analysis tool > [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential > NPE. Our analysis shows that some callees may return null in corner case(e.g. > node crash , IO exception), some of their callers have _!=null_ check but > some do not have. In this issue we post a patch which can add !=null based > on existed !=null check. For example: > Calle Schema#getView may return null: > {code:java} > public ViewMetadata getView(String keyspaceName, String viewName) > { > assert keyspaceName != null; > KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); > return (ksm == null) ? null : ksm.views.getNullable(viewName);//may > return null > } > {code} > it have 4 callers, 3 of them have !=null check, like its caller > MigrationManager#announceViewDrop have !=null check() > {code:java} > public static void announceViewDrop(String ksName, String viewName, boolean > announceLocally) throws ConfigurationException > { >ViewMetadata view = Schema.instance.getView(ksName, viewName); > if (view == null)//null pointer checker > throw new ConfigurationException(String.format("Cannot drop non > existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); >KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); >logger.info("Drop table '{}/{}'", view.keyspace, view.name); >announce(SchemaKeyspace.makeDropViewMutation(ksm, view, > FBUtilities.timestampMicros()), announceLocally); > } > {code} > but caller MigrationManager#announceMigration does not have > We add !=null check based on MigrationManager#announceViewDrop: > {code:java} > if (current == null) > throw new InvalidRequestException("There is no materialized view in > keyspace " + keyspace()); > {code} > But due to we are not very familiar with CASSANDRA, hope some expert can > review it. > Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Updated] (CASSANDRA-14385) Fix Some Potential NPE
[ https://issues.apache.org/jira/browse/CASSANDRA-14385?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] lujie updated CASSANDRA-14385: -- Description: We have developed a static analysis tool [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential NPE. Our analysis shows that some callees may return null in corner case(e.g. node crash , IO exception), some of their callers have _!=null_ check but some do not have. In this issue we post a patch which can add !=null based on existed !=null check. For example: Calle Schema#getView may return null: {code:java} public ViewMetadata getView(String keyspaceName, String viewName) { assert keyspaceName != null; KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); return (ksm == null) ? null : ksm.views.getNullable(viewName);//may return null } {code} it have 4 callers, 3 of them have !=null check, like its caller MigrationManager#announceViewDrop have !=null check() {code:java} public static void announceViewDrop(String ksName, String viewName, boolean announceLocally) throws ConfigurationException { ViewMetadata view = Schema.instance.getView(ksName, viewName); if (view == null)//null pointer checker throw new ConfigurationException(String.format("Cannot drop non existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); logger.info("Drop table '{}/{}'", view.keyspace, view.name); announce(SchemaKeyspace.makeDropViewMutation(ksm, view, FBUtilities.timestampMicros()), announceLocally); } {code} but caller MigrationManager#announceMigration does not have We add !=null check based on MigrationManager#announceViewDrop: {code:java} if (current == null) throw new InvalidRequestException("There is no materialized view in keyspace " + keyspace()); {code} But due to we are not very familiar with CASSANDRA, hope some expert can review it. Thanks was: We have developed a static analysis tool [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential NPE. Our analysis shows that some callees may return null in corner case(e.g. node crash , IO exception), some of their callers have _!=null_ check but some do not have. In this issue we post a patch which can add !=null based on existed !=null check. For example: Calle Schema#getView may return null: {code:java} public ViewMetadata getView(String keyspaceName, String viewName) { assert keyspaceName != null; KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); return (ksm == null) ? null : ksm.views.getNullable(viewName); } {code} it have 4 callers, 3 of them have !=null check, like its caller MigrationManager#announceViewDrop have !=null check() {code:java} public static void announceViewDrop(String ksName, String viewName, boolean announceLocally) throws ConfigurationException { ViewMetadata view = Schema.instance.getView(ksName, viewName); if (view == null) throw new ConfigurationException(String.format("Cannot drop non existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); logger.info("Drop table '{}/{}'", view.keyspace, view.name); announce(SchemaKeyspace.makeDropViewMutation(ksm, view, FBUtilities.timestampMicros()), announceLocally); } {code} but caller MigrationManager#announceMigration does not have We add !=null check based on MigrationManager#announceViewDrop: {code:java} if (current == null) throw new InvalidRequestException("There is no materialized view in keyspace " + keyspace()); {code} But due to we are not very familiar with CASSANDRA, hope some expert can review it. Thanks > Fix Some Potential NPE > --- > > Key: CASSANDRA-14385 > URL: https://issues.apache.org/jira/browse/CASSANDRA-14385 > Project: Cassandra > Issue Type: Bug >Reporter: lujie >Priority: Major > Attachments: CA-14385_1.patch > > > We have developed a static analysis tool > [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential > NPE. Our analysis shows that some callees may return null in corner case(e.g. > node crash , IO exception), some of their callers have _!=null_ check but > some do not have. In this issue we post a patch which can add !=null based > on existed !=null check. For example: > Calle Schema#getView may return null: > {code:java} > public ViewMetadata getView(String keyspaceName, String viewName) > { > assert keyspaceName != null; > KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); > return (ksm == null) ? null : ksm.views.getNullable(viewName);//may > return null > } > {code} > it have 4 callers, 3 of them have !=null check, like its caller > MigrationManager#announceViewDrop have !=null
[jira] [Updated] (CASSANDRA-14385) Fix Some Potential NPE
[ https://issues.apache.org/jira/browse/CASSANDRA-14385?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] lujie updated CASSANDRA-14385: -- Description: We have developed a static analysis tool [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential NPE. Our analysis shows that some callees may return null in corner case(e.g. node crash , IO exception), some of their callers have _!=null_ check but some do not have. In this issue we post a patch which can add !=null based on existed !=null check. For example: Calle Schema#getView may return null: {code:java} public ViewMetadata getView(String keyspaceName, String viewName) { assert keyspaceName != null; KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); return (ksm == null) ? null : ksm.views.getNullable(viewName); } {code} it have 4 callers, 3 of them have !=null check, like its caller MigrationManager#announceViewDrop have !=null check() {code:java} public static void announceViewDrop(String ksName, String viewName, boolean announceLocally) throws ConfigurationException { ViewMetadata view = Schema.instance.getView(ksName, viewName); if (view == null) throw new ConfigurationException(String.format("Cannot drop non existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); logger.info("Drop table '{}/{}'", view.keyspace, view.name); announce(SchemaKeyspace.makeDropViewMutation(ksm, view, FBUtilities.timestampMicros()), announceLocally); } {code} but caller MigrationManager#announceMigration does not have We add !=null check based on MigrationManager#announceViewDrop: {code:java} if (current == null) throw new InvalidRequestException("There is no materialized view in keyspace " + keyspace()); {code} But due to we are not very familiar with CASSANDRA, hope some expert can review it. Thanks was: We have developed a static analysis tool [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential NPE. Our analysis shows that some callees may return null in corner case(e.g. node crash , IO exception), some of their callers have _!=null_ check but some do not have. In this issue we post a patch which can add !=null based on existed !=null check. For example: Calle Schema#getView may return null: {code:java} public ViewMetadata getView(String keyspaceName, String viewName) { assert keyspaceName != null; KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); return (ksm == null) ? null : ksm.views.getNullable(viewName); } {code} it have 4 callers, 3 of them have !=null check, like its caller MigrationManager#announceViewDrop have !=null check() {code:java} public static void announceViewDrop(String ksName, String viewName, boolean announceLocally) throws ConfigurationException { ViewMetadata view = Schema.instance.getView(ksName, viewName); if (view == null) throw new ConfigurationException(String.format("Cannot drop non existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); logger.info("Drop table '{}/{}'", view.keyspace, view.name); announce(SchemaKeyspace.makeDropViewMutation(ksm, view, FBUtilities.timestampMicros()), announceLocally); } {code} but caller MigrationManager#announceMigration does not have We add !=null check based on MigrationManager#announceViewDrop: {code:java} if (current == null) throw new InvalidRequestException("There is no materialized view in keyspace " + keyspace()); {code} But due to we are not very familiar with CASSANDRA, hope some expert can review it. Thanks > Fix Some Potential NPE > --- > > Key: CASSANDRA-14385 > URL: https://issues.apache.org/jira/browse/CASSANDRA-14385 > Project: Cassandra > Issue Type: Bug >Reporter: lujie >Priority: Major > Attachments: CA-14385_1.patch > > > We have developed a static analysis tool > [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential > NPE. Our analysis shows that some callees may return null in corner case(e.g. > node crash , IO exception), some of their callers have _!=null_ check but > some do not have. In this issue we post a patch which can add !=null based > on existed !=null check. For example: > Calle Schema#getView may return null: > {code:java} > public ViewMetadata getView(String keyspaceName, String viewName) > { > assert keyspaceName != null; > KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); > return (ksm == null) ? null : ksm.views.getNullable(viewName); > } > {code} > it have 4 callers, 3 of them have !=null check, like its caller > MigrationManager#announceViewDrop have !=null check() > {code:java} > public static void announceViewDrop(String ksName, String viewName, boolean > announceLocal
[jira] [Updated] (CASSANDRA-14385) Fix Some Potential NPE
[ https://issues.apache.org/jira/browse/CASSANDRA-14385?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] lujie updated CASSANDRA-14385: -- Attachment: CA-14385_1.patch > Fix Some Potential NPE > --- > > Key: CASSANDRA-14385 > URL: https://issues.apache.org/jira/browse/CASSANDRA-14385 > Project: Cassandra > Issue Type: Bug >Reporter: lujie >Priority: Major > Attachments: CA-14385_1.patch > > > We have developed a static analysis tool > [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential > NPE. Our analysis shows that some callees may return null in corner case(e.g. > node crash , IO exception), some of their callers have _!=null_ check but > some do not have. In this issue we post a patch which can add !=null based > on existed !=null check. For example: > Calle Schema#getView may return null: > {code:java} > public ViewMetadata getView(String keyspaceName, String viewName) > { > assert keyspaceName != null; > KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); > return (ksm == null) ? null : ksm.views.getNullable(viewName); > } > {code} > it have 4 callers, 3 of them have !=null check, like its caller > MigrationManager#announceViewDrop have !=null check() > {code:java} > public static void announceViewDrop(String ksName, String viewName, boolean > announceLocally) throws ConfigurationException > { > ViewMetadata view = Schema.instance.getView(ksName, viewName); > if (view == null) > throw new ConfigurationException(String.format("Cannot drop non existing > materialized view '%s' in keyspace '%s'.", viewName, ksName)); > KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); > logger.info("Drop table '{}/{}'", view.keyspace, view.name); > announce(SchemaKeyspace.makeDropViewMutation(ksm, view, > FBUtilities.timestampMicros()), announceLocally); > } > {code} > but caller MigrationManager#announceMigration does not have > We add !=null check based on MigrationManager#announceViewDrop: > {code:java} > if (current == null) > throw new InvalidRequestException("There is no materialized view in keyspace > " + keyspace()); > {code} > But due to we are not very familiar with CASSANDRA, hope some expert can > review it. Thanks > -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Updated] (CASSANDRA-14385) Fix Some Potential NPE
[ https://issues.apache.org/jira/browse/CASSANDRA-14385?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] lujie updated CASSANDRA-14385: -- Description: We have developed a static analysis tool [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential NPE. Our analysis shows that some callees may return null in corner case(e.g. node crash , IO exception), some of their callers have _!=null_ check but some do not have. In this issue we post a patch which can add !=null based on existed !=null check. For example: Calle Schema#getView may return null: {code:java} public ViewMetadata getView(String keyspaceName, String viewName) { assert keyspaceName != null; KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); return (ksm == null) ? null : ksm.views.getNullable(viewName); } {code} it have 4 callers, 3 of them have !=null check, like its caller MigrationManager#announceViewDrop have !=null check() {code:java} public static void announceViewDrop(String ksName, String viewName, boolean announceLocally) throws ConfigurationException { ViewMetadata view = Schema.instance.getView(ksName, viewName); if (view == null) throw new ConfigurationException(String.format("Cannot drop non existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); logger.info("Drop table '{}/{}'", view.keyspace, view.name); announce(SchemaKeyspace.makeDropViewMutation(ksm, view, FBUtilities.timestampMicros()), announceLocally); } {code} but caller MigrationManager#announceMigration does not have We add !=null check based on MigrationManager#announceViewDrop: {code:java} if (current == null) throw new InvalidRequestException("There is no materialized view in keyspace " + keyspace()); {code} But due to we are not very familiar with CASSANDRA, hope some expert can review it. Thanks was: We have developed a static analysis tool [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential NPE. Our analysis shows that some callees may return null in corner case(e.g. node crash , IO exception), some of their callers have _!=null_ check but some do not have. In this issue we post a patch which can add !=null based on existed !=null check. For example: Calle Schema#getView may return null: {code:java} public ViewMetadata getView(String keyspaceName, String viewName) { assert keyspaceName != null; KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); return (ksm == null) ? null : ksm.views.getNullable(viewName); } {code} it have 4 callers, 3 of them have !=null check, like its caller MigrationManager#announceViewDrop have !=null check() {code:java} public static void announceViewDrop(String ksName, String viewName, boolean announceLocally) throws ConfigurationException { ViewMetadata view = Schema.instance.getView(ksName, viewName); if (view == null) throw new ConfigurationException(String.format("Cannot drop non existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); logger.info("Drop table '{}/{}'", view.keyspace, view.name); announce(SchemaKeyspace.makeDropViewMutation(ksm, view, FBUtilities.timestampMicros()), announceLocally); } {code} but caller MigrationManager#announceMigration does not have We add !=null check based on MigrationManager#announceViewDrop: {code:java} if (current == null) throw new InvalidRequestException("There is no materialized view in keyspace " + keyspace()); {code} But due to we are not very familiar with CASSANDRA, hope some expert can review it. Thanks > Fix Some Potential NPE > --- > > Key: CASSANDRA-14385 > URL: https://issues.apache.org/jira/browse/CASSANDRA-14385 > Project: Cassandra > Issue Type: Bug >Reporter: lujie >Priority: Major > > We have developed a static analysis tool > [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential > NPE. Our analysis shows that some callees may return null in corner case(e.g. > node crash , IO exception), some of their callers have _!=null_ check but > some do not have. In this issue we post a patch which can add !=null based > on existed !=null check. For example: > Calle Schema#getView may return null: > {code:java} > public ViewMetadata getView(String keyspaceName, String viewName) > { > assert keyspaceName != null; > KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); > return (ksm == null) ? null : ksm.views.getNullable(viewName); > } > {code} > it have 4 callers, 3 of them have !=null check, like its caller > MigrationManager#announceViewDrop have !=null check() > {code:java} > public static void announceViewDrop(String ksName, String viewName, boolean > announceLocally) throws ConfigurationException > { > Vie
[jira] [Updated] (CASSANDRA-14385) Fix Some Potential NPE
[ https://issues.apache.org/jira/browse/CASSANDRA-14385?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] lujie updated CASSANDRA-14385: -- Description: We have developed a static analysis tool [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential NPE. Our analysis shows that some callees may return null in corner case(e.g. node crash , IO exception), some of their callers have _!=null_ check but some do not have. In this issue we post a patch which can add !=null based on existed !=null check. For example: Calle Schema#getView may return null: {code:java} public ViewMetadata getView(String keyspaceName, String viewName) { assert keyspaceName != null; KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); return (ksm == null) ? null : ksm.views.getNullable(viewName); } {code} it have 4 callers, 3 of them have !=null check, like its caller MigrationManager#announceViewDrop have !=null check() {code:java} public static void announceViewDrop(String ksName, String viewName, boolean announceLocally) throws ConfigurationException { ViewMetadata view = Schema.instance.getView(ksName, viewName); if (view == null) throw new ConfigurationException(String.format("Cannot drop non existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); logger.info("Drop table '{}/{}'", view.keyspace, view.name); announce(SchemaKeyspace.makeDropViewMutation(ksm, view, FBUtilities.timestampMicros()), announceLocally); } {code} but caller MigrationManager#announceMigration does not have We add !=null check based on MigrationManager#announceViewDrop: {code:java} if (current == null) throw new InvalidRequestException("There is no materialized view in keyspace " + keyspace()); {code} But due to we are not very familiar with CASSANDRA, hope some expert can review it. Thanks was: We have developed a static analysis tool [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential NPE. Our analysis shows that some callees may return null in corner case(e.g. node crash , IO exception), some of their callers have _!=null_ check but some do not have. In this issue we post a patch which can add !=null based on existed !=null check. For example: Calle Schema#getView may return null: {code:java} public ViewMetadata getView(String keyspaceName, String viewName) { assert keyspaceName != null; KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); return (ksm == null) ? null : ksm.views.getNullable(viewName); } {code} it have 4 callers, 3 of them have !=null check, like its caller MigrationManager#announceViewDrop have \!=null check() {code:java} public static void announceViewDrop(String ksName, String viewName, boolean announceLocally) throws ConfigurationException { ViewMetadata view = Schema.instance.getView(ksName, viewName); if (view == null) throw new ConfigurationException(String.format("Cannot drop non existing materialized view '%s' in keyspace '%s'.", viewName, ksName)); KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(ksName); logger.info("Drop table '{}/{}'", view.keyspace, view.name); announce(SchemaKeyspace.makeDropViewMutation(ksm, view, FBUtilities.timestampMicros()), announceLocally); } {code} but caller MigrationManager#announceMigration does not have We add \!=null check based on MigrationManager#announceViewDrop: {code:java} if (current == null) throw new InvalidRequestException("There is no materialized view in keyspace " + keyspace()); {code} But due to we are not very familiar with CASSANDRA, hope some expert can review it. Thanks > Fix Some Potential NPE > --- > > Key: CASSANDRA-14385 > URL: https://issues.apache.org/jira/browse/CASSANDRA-14385 > Project: Cassandra > Issue Type: Bug >Reporter: lujie >Priority: Major > > We have developed a static analysis tool > [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential > NPE. Our analysis shows that some callees may return null in corner case(e.g. > node crash , IO exception), some of their callers have _!=null_ check but > some do not have. In this issue we post a patch which can add !=null based > on existed !=null check. For example: > Calle Schema#getView may return null: > {code:java} > public ViewMetadata getView(String keyspaceName, String viewName) > { > assert keyspaceName != null; > KeyspaceMetadata ksm = keyspaces.getNullable(keyspaceName); > return (ksm == null) ? null : ksm.views.getNullable(viewName); > } > {code} > it have 4 callers, 3 of them have !=null check, like > its caller MigrationManager#announceViewDrop have !=null check() > {code:java} > public static void announceViewDrop(String ksName, String viewName, boolean > announceLocally) throws ConfigurationException