# A Null pointer cannot be detected

**URL:** <https://community.sonarsource.com/t/a-null-pointer-cannot-be-detected/133438>\
**Category:** Report False-positive / False-negative...\
**Tags:** java\
**Created:** [January 14, 2025, 2:11pm UTC](https://community.sonarsource.com/t/a-null-pointer-cannot-be-detected/133438 "2025-01-14T14:11:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emily\_Wei](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/emily_wei/32/65842_2.png) [@Emily\_Wei](https://community.sonarsource.com/u/Emily_Wei)\
**Post date:** [January 14, 2025, 2:11pm UTC](https://community.sonarsource.com/t/a-null-pointer-cannot-be-detected/133438/1 "2025-01-14T14:11:31Z")

</div>

Hello,  
`SubPlatformEnum e` is a Null pointer. Why can’t this Null pointer be detected? It might be rule [S2259]  
com/example/webtemp/SubPlatformEnum.java

```auto
package com.example.webtemp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class WebTempApplication {
    public static void main(String[] args) {
        int a = 0;
        SubPlatformEnum e = SubPlatformEnum.fromIntValue(a);
        System.out.println(e.getValue());
        SpringApplication.run(WebTempApplication.class, args);
    }
}

```

com/example/webtemp/WebTempApplication.java

```auto
package com.example.webtemp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class WebTempApplication {
    public static void main(String[] args) {
        int a = 0;
        SubPlatformEnum e = SubPlatformEnum.fromIntValue(a);
        System.out.println(e.getValue());
        SpringApplication.run(WebTempApplication.class, args);
    }
}

```

pom.xml

```auto
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.7.18</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>web-temp</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>web-temp</name>
	<description>web-temp</description>
	<url/>
	<licenses>
		<license/>
	</licenses>
	<developers>
		<developer/>
	</developers>
	<scm>
		<connection/>
		<developerConnection/>
		<tag/>
		<url/>
	</scm>
	<properties>
		<java.version>11</java.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
			<version>32.1.2-jre</version> 
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-collections4</artifactId>
			<version>4.4</version> 
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.10.1</version>
				<configuration>
					<annotationProcessorPaths>
						<path>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
							<version>1.18.30</version>
						</path>
					</annotationProcessorPaths>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
						</exclude>
					</excludes>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>

```

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [January 15, 2025, 9:25am UTC](https://community.sonarsource.com/t/a-null-pointer-cannot-be-detected/133438/2 "2025-01-15T09:25:55Z")

</div>

Hey there.

What version of what product are you using to analyze your code? SonarQube Server, SonarQube for IDE, SonarQube Cloud (in which case there is no version)

---

<div class="post-metadata">

**Author:** ![Emily\_Wei](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/emily_wei/32/65842_2.png) [@Emily\_Wei](https://community.sonarsource.com/u/Emily_Wei)\
**Post date:** [January 15, 2025, 9:58am UTC](https://community.sonarsource.com/t/a-null-pointer-cannot-be-detected/133438/3 "2025-01-15T09:58:24Z")

</div>

Either the ide or server can‘t .in the Latest version.U can have a try with my code

---

<div class="post-metadata">

**Author:** ![tomasz.tylenda](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomasz.tylenda/32/77387_2.png) [@tomasz.tylenda](https://community.sonarsource.com/u/tomasz.tylenda)\
**Post date:** [January 30, 2025, 11:10am UTC](https://community.sonarsource.com/t/a-null-pointer-cannot-be-detected/133438/6 "2025-01-30T11:10:46Z")

</div>

Hi Emily,

Both files in your first post are identical. Could you please provide us with the contents of `SubPlatformEnum.java`, so we can reproduce the problem?
