CASSANDRA-18785: Add support for Sonar analysis

Patch by Jacek Lewandowski; reviewed by Brandon Williams, Maxim Muzafarov, Michael Semb Wever, Stefan Miklosovic for CASSANDRA-18785
This commit is contained in:
Jacek Lewandowski 2023-08-22 10:47:29 +02:00
parent 0e4c2f4bef
commit 4d61359c21
200 changed files with 551 additions and 315 deletions

View File

@ -29,6 +29,66 @@ The following applies to all build scripts.
build_dir=/tmp/cass_Mtu462n .build/docker/check-code.sh
Running Sonar analysis (experimental)
-------------------------------------
Run:
ant sonar
Sonar analysis requires the SonarQube server to be available. If there
is already some SonarQube server, it can be used by setting the
following env variables:
SONAR_HOST_URL=http://sonar.example.com
SONAR_CASSANDRA_TOKEN=cassandra-project-analysis-token
SONAR_PROJECT_KEY=<key of the Cassandra project in SonarQube>
If SonarQube server is not available, one can be started locally in
a Docker container. The following command will create a SonarQube
container and start the server:
ant sonar-create-server
The server will be available at http://localhost:9000 with admin
credentials admin/password. The Docker container named `sonarqube`
is created and left running. When using this local SonarQube server,
no env variables to configure url, token, or project key are needed,
and the analysis can be run right away with `ant sonar`.
After the analysis, the server remains running so that one can
inspect the results.
To stop the local SonarQube server:
ant sonar-stop-server
However, this command just stops the Docker container without removing
it. It allows to start the container later with:
docker container start sonarqube
and access previous analysis results. To drop the container, run:
docker container rm sonarqube
When `SONAR_HOST_URL` is not provided, the script assumes a dedicated
local instance of the SonarQube server and sets it up automatically,
which includes creating a project, setting up the quality profile, and
quality gate from the configuration stored in
[sonar-quality-profile.xml](sonar%2Fsonar-quality-profile.xml) and
[sonar-quality-gate.json](sonar%2Fsonar-quality-gate.json)
respectively. To run the analysis with a custom quality profile, start
the server using `ant sonar-create-server`, create a project manually,
and set up a desired quality profile for it. Then, create the analysis
token for the project and export the following env variables:
SONAR_HOST_URL="http://127.0.0.1:9000"
SONAR_CASSANDRA_TOKEN="<token>"
SONAR_PROJECT_KEY="<key of the Cassandra project in SonarQube>"
The analysis can be run with `ant sonar`.
Building Artifacts (tarball and maven)
-------------------------------------

View File

@ -51,5 +51,20 @@
</condition>
<echo level="warning" if:true="${is-dirty}">Repository state is dirty</echo>
<echo level="warning" if:true="${is-dirty}">${git.diffstat}</echo>
<exec if:true="${git.is-available}" executable="bash" dir="${basedir}" logError="true" failonerror="false" failifexecutionfails="false">
<arg value="-c"/>
<arg value="([[ -f .git ]] &amp;&amp; (basename `cat .git | cut -f 2 -d ' '`)) || (basename `pwd`)"/>
<redirector outputproperty="git.worktree.name"/>
</exec>
<echo message="git.worktree.name=${git.worktree.name}"/>
<exec if:true="${git.is-available}" executable="bash" dir="${basedir}" logError="true" failonerror="false" failifexecutionfails="false">
<arg value="-c"/>
<arg value="git branch --show-current"/>
<redirector outputproperty="git.branch.name"/>
</exec>
<echo message="git.branch.name=${git.branch.name}"/>
</target>
</project>

View File

@ -45,6 +45,7 @@
<exclude name="**/cassandra*.yaml"/>
<exclude NAME="doc/antora.yml"/>
<exclude name="ide/**/*"/>
<exclude name="**/*.json"/>
<exclude name="pylib/cqlshlib/test/config/sslhandling*.config"/>
<exclude NAME="src/resources/org/apache/cassandra/cql3/reserved_keywords.txt"/>
<exclude NAME="src/resources/org/apache/cassandra/index/sasi/analyzer/filter/*.txt"/>
@ -59,7 +60,6 @@
<exclude name="pylib/cqlshlib/test/test_authproviderhandling_config/*"/>
<exclude name="test/**/cassandra*.conf"/>
<exclude name="test/**/*.csv"/>
<exclude name="test/**/*.json"/>
<exclude name="test/**/*.txt"/>
<exclude name="test/data/**/*.adler32"/>
<exclude name="test/data/**/*.crc32"/>

247
.build/build-sonar.xml Normal file
View File

@ -0,0 +1,247 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project basedir="." name="apache-cassandra-sonar-tasks" xmlns:if="ant:if" xmlns:unless="ant:unless">
<property name="sonar-scanner-cli.version" value="5.0.1.3006"/>
<property name="sonar.workdir" value="${build.dir}/sonar"/>
<property name="sonar.download.dir" value="${tmp.dir}/sonar"/>
<property name="sonar-scanner.home" value="${sonar.download.dir}/sonar-scanner-${sonar-scanner-cli.version}"/>
<property name="sonar.mainBranch" value="trunk"/>
<property name="sonar.host.url.default" value="http://127.0.0.1:9000"/>
<target name="-sonar-init" depends="_get-git-sha">
<exec executable="date" failifexecutionfails="true" failonerror="true" logerror="true">
<arg value="+%Y-%m-%d-%H-%M-%S"/>
<redirector outputproperty="timestamp" alwayslog="true">
</redirector>
</exec>
<mkdir dir="${sonar.download.dir}"/>
<mkdir dir="${sonar-scanner.home}"/>
<mkdir dir="${sonar.workdir}"/>
<mkdir dir="${sonar.workdir}/scanner"/>
<mkdir dir="${sonar.workdir}/scanner/fake"/>
<condition property="git.repo.version" value="${git.sha}" else="${git.branch.name}">
<equals arg1="${git.branch.name}" arg2=""/>
</condition>
<condition property="sonar.projectKey" value="${env.SONAR_PROJECT_KEY}" else="${git.repo.version}-${git.worktree.name}">
<isset property="env.SONAR_PROJECT_KEY"/>
</condition>
<echo message="sonar.projectKey=${sonar.projectKey}"/>
</target>
<target name="-init-sonar-scanner-cli" depends="-sonar-init" unless="sonar-scanner.downloaded">
<local name="sonar-scanner.downloaded"/>
<available file="${sonar-scanner.home}/bin/sonar-scanner" property="sonar-scanner.downloaded"/>
<sequential unless:set="sonar-scanner.downloaded">
<echo>Downloading Sonar-Scanner CLI...</echo>
<retry retrycount="3" retrydelay="5000" >
<get src="https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${sonar-scanner-cli.version}.zip"
dest="${sonar.download.dir}/sonar-scanner-cli-${sonar-scanner-cli.version}.zip"/>
</retry>
<unzip src="${sonar.download.dir}/sonar-scanner-cli-${sonar-scanner-cli.version}.zip" dest="${sonar.download.dir}" overwrite="true"/>
<setpermissions mode="755" failonerror="false">
<!-- unzip task in Ant does not preserve file permissions, so we need to make those files executable explicitly -->
<file file="${sonar-scanner.home}/bin/sonar-scanner" />
</setpermissions>
</sequential>
<!-- Sonar Scanner CLI needs to run with Java 17 - we either use the current java.home or env.JAVA17_HOME -->
<condition property="sonarJavaHome" value="${java.home}">
<or>
<equals arg1="${ant.java.version}" arg2="17"/>
</or>
</condition>
<condition property="sonarJavaHome" value="${env.JAVA17_HOME}">
<and>
<not>
<equals arg1="${ant.java.version}" arg2="17"/>
</not>
<isset property="env.JAVA17_HOME"/>
</and>
</condition>
<fail unless="sonarJavaHome"
message="You must either run Ant with Java 17 or point Java 17 home in JAVA17_HOME env variable"/>
<echo message="Using Java home: ${sonarJavaHome}"/>
</target>
<macrodef name="check-server-status">
<attribute name="url"/>
<sequential>
<local name="sonar.server.status"/>
<exec executable="curl" failifexecutionfails="false" failonerror="false" logerror="false">
<arg value="-s"/>
<arg value="@{url}/api/system/status"/>
<redirector outputproperty="sonar.server.status" alwayslog="true">
<outputfilterchain>
<tokenfilter>
<replaceregex pattern=".*&quot;status&quot;:&quot;([^&quot;]+)&quot;.*" replace="\1"/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
<echo message="SonarQube server status: ${sonar.server.status}"/>
<condition property="sonar.server.running" value="true">
<equals arg1="${sonar.server.status}" arg2="UP"/>
</condition>
<fail unless="sonar.server.running" message="Running SonarQube server is not available at ${sonar.host.url}. You can create a SonarQube server container using `ant sonar-create-server` task, or if you did that before, start it using `docker container start sonarqube` and wait until the web service is available."/>
</sequential>
</macrodef>
<target name="-init-sonar-server" depends="-sonar-init,-maybe-set-external-sonar-server-url,-maybe-setup-local-sonar-server">
<check-server-status url="${sonar.host.url}"/>
</target>
<target name="-maybe-set-external-sonar-server-url" depends="-sonar-init" if="env.SONAR_HOST_URL">
<property name="sonar.host.url" value="${env.SONAR_HOST_URL}"/>
<fail unless="env.SONAR_CASSANDRA_TOKEN" message="SONAR_CASSANDRA_TOKEN environment variable must be set when using Sonar server defined in env SONAR_HOST_URL"/>
<property name="sonar.token" value="${env.SONAR_CASSANDRA_TOKEN}"/>
</target>
<!-- We run this target only if we are using the local server - that is, a custom SONAR_HOST_URL env is not provided -->
<target name="-maybe-setup-local-sonar-server" depends="-sonar-init" unless="env.SONAR_HOST_URL">
<property name="sonar.host.url" value="${sonar.host.url.default}"/>
<!-- Fail if the server is not running -->
<check-server-status url="${sonar.host.url}"/>
<exec executable="${build.helpers.dir}/sonar/sonar-setup-local.sh" failifexecutionfails="true" failonerror="true" logerror="true">
<env key="SONAR_HOST_URL" value="${sonar.host.url}"/>
<env key="SONAR_PROJECT_KEY" value="${sonar.projectKey}"/>
<arg line="admin:password"/>
<arg line="${build.helpers.dir}/sonar/sonar-quality-profile.xml"/>
<arg line="${build.helpers.dir}/sonar/sonar-quality-gate.json"/>
<redirector outputproperty="sonar.token"/>
</exec>
</target>
<target name="sonar-stop-server" depends="-sonar-init" description="Stos the local Sonar server without removing the container">
<exec executable="docker" dir="${sonar.workdir}" failifexecutionfails="true" failonerror="true" logerror="true">
<arg value="stop"/>
<arg value="sonarqube"/>
</exec>
<echo message="SonarQube server stopped. To start the container again to inspect the analysis results, run `docker start sonarqube`. To remove the container entirely run `docker rm sonarqube`"/>
</target>
<target name="sonar-create-server" depends="-sonar-init" description="Create a Docker container with SonarQube community server. This task will fail if the server named sonarqube already exists">
<property name="sonar.host.url" value="${sonar.host.url.default}"/>
<!-- Create docker container-->
<exec executable="docker" dir="${sonar.workdir}" failifexecutionfails="true" failonerror="true" logerror="true">
<arg value="run"/>
<arg value="-d"/>
<arg value="--name"/>
<arg value="sonarqube"/>
<arg value="-e"/>
<arg value="SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true"/>
<arg value="-p"/>
<arg value="9000:9000"/>
<arg value="-v"/>
<arg value="/opt/sonarqube/data"/>
<arg value="-v"/>
<arg value="/opt/sonarqube/logs"/>
<arg value="-v"/>
<arg value="/opt/sonarqube/extensions"/>
<arg value="sonarqube:community"/>
</exec>
<!-- Wait for SonarQube server to be ready-->
<retry retrycount="60" retrydelay="1000">
<check-server-status url="${sonar.host.url}"/>
</retry>
<!-- A fresh SonarQube server requires changing the initial admin credentials - we update it here to admin:password -->
<exec executable="curl" failifexecutionfails="true" failonerror="true" logerror="true">
<arg line="-u admin:admin"/>
<arg line="-X POST"/>
<arg line="-s"/>
<arg value="${sonar.host.url}/api/users/change_password?login=admin&amp;password=password&amp;previousPassword=admin"/>
</exec>
<!-- Disable forcing authentication for browsing analysis -->
<exec executable="curl" failifexecutionfails="true" failonerror="true" logerror="true">
<arg line="-u admin:password"/>
<arg line="-X POST"/>
<arg line="-s"/>
<arg value="${sonar.host.url}/api/settings/set?key=sonar.forceAuthentication&amp;value=false"/>
</exec>
</target>
<macrodef name="sonar-report" description="Creates the offline report by fetching all project issues and converting them into HTML">
<sequential>
<echo message="Generating SonarQube analysis offline report"/>
<exec executable="${build.helpers.dir}/sonar/sonar-report.sh" failifexecutionfails="false" failonerror="false" logerror="true">
<env key="SONAR_HOST_URL" value="${sonar.host.url}"/>
<env key="SONAR_CASSANDRA_TOKEN" value="${sonar.token}"/>
<env key="SONAR_PROJECT_KEY" value="${sonar.projectKey}"/>
<arg value="${sonar.workdir}/sonar-report-main.json"/>
<arg value="BLOCKER,CRITICAL,MAJOR"/>
<arg value="MAIN"/>
</exec>
<echo message="SonarQube report saved to file://${sonar.workdir}/sonar-report-main.json"/>
</sequential>
</macrodef>
<target name="sonar" depends="_get-git-sha,-init-sonar-scanner-cli,-init-sonar-server" description="Run the Sonar analysis on the project">
<fail unless="sonar.token" message="sonar.token property must be set"/>
<condition property="should_run_preanalysis" value="true">
<and>
<not>
<isset property="env.SONAR_HOST_URL"/>
</not>
<not>
<isset property="env.SONAR_PROJECT_KEY"/>
</not>
</and>
</condition>
<!-- Run the analysis on the project -->
<echo message="Running Sonar analysis on the project"/>
<exec executable="${sonar-scanner.home}/bin/sonar-scanner" failifexecutionfails="true" failonerror="false" logerror="true" resultproperty="analysis_result">
<env key="JAVA_HOME" value="${sonarJavaHome}"/>
<arg value="-Dsonar.host.url=${sonar.host.url}"/>
<arg value="-Dsonar.token=${sonar.token}"/>
<arg value="-Dsonar.projectKey=${sonar.projectKey}"/>
<arg value="-Dsonar.working.directory=${sonar.workdir}/scanner"/>
<arg value="-Dsonar.sourceEncoding=UTF-8"/>
<arg value="-Dsonar.scm.disabled=true"/>
<arg value="-Dsonar.sources=${build.src.java},${fqltool.build.src},${stress.build.src}"/>
<arg value="-Dsonar.java.libraries=${build.dir.lib}/jars/jsr305-*.jar"/>
<arg value="-Dsonar.java.binaries=${build.classes.main},${fqltool.build.classes},${stress.build.classes}"/>
<arg value="-Dsonar.java.source=11"/>
<arg value="-Dsonar.projectVersion=${timestamp}"/>
<arg value="-Dsonar.qualitygate.wait=true"/>
</exec>
<!-- Generate a simplified report which will be available even when the Sonar server contianer is stopped -->
<sonar-report/>
<!-- We postponed faling the build until the offline report is created -->
<condition property="analysis_succeeded" value="true">
<equals arg1="${analysis_result}" arg2="0"/>
</condition>
<fail unless="analysis_succeeded" message="Sonar analysis failed"/>
</target>
</project>

View File

@ -0,0 +1,22 @@
{
"name": "cassandra",
"conditions": [
{
"id": "AYuvOs-pRzmON3lNOtmB",
"metric": "blocker_violations",
"op": "GT",
"error": "0"
}
],
"isBuiltIn": false,
"actions": {
"rename": true,
"setAsDefault": true,
"copy": true,
"associateProjects": true,
"delete": true,
"manageConditions": true,
"delegate": true
},
"caycStatus": "compliant"
}

View File

@ -0,0 +1,30 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<profile>
<name>cassandra</name>
<language>java</language>
<rules>
<rule>
<repositoryKey>java</repositoryKey>
<key>S2095</key>
<type>BUG</type>
<priority>BLOCKER</priority>
<parameters/>
</rule>
</rules>
</profile>

66
.build/sonar/sonar-report.sh Executable file
View File

@ -0,0 +1,66 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e
REPORT_FILE="${1:-sonar-report.json}"
SEVERITIES="${2:-BLOCKER,CRITICAL,MAJOR}"
SCOPE=${3:-MAIN}
if [ -z "$SONAR_HOST_URL" ]; then
SONAR_HOST_URL="http://127.0.0.1:9000"
fi
if [ -z "$SONAR_PROJECT_KEY" ]; then
echo "SONAR_PROJECT_KEY is not set"
exit 1
fi
rm -f "$REPORT_FILE"
# Maximum page size is 500, maximum number of returned issues is 10000
for i in $(seq 1 20); do
if [ -n "$SONAR_CASSANDRA_TOKEN" ]; then
curl -sS --header "Authorization: Bearer ${SONAR_CASSANDRA_TOKEN}" "$SONAR_HOST_URL/api/issues/search?s=SEVERITY&asc=false&scopes=${SCOPE}&severities=${SEVERITIES}&components=${SONAR_PROJECT_KEY}&ps=500&p=$i" -o "${REPORT_FILE}.page"
else
curl -sS "$SONAR_HOST_URL/api/issues/search?s=SEVERITY&asc=false&scopes=${SCOPE}&severities=${SEVERITIES}&components=${SONAR_PROJECT_KEY}&ps=500&p=$i" -o "${REPORT_FILE}.page"
fi
if [ ! -s "${REPORT_FILE}.page" ]; then
echo "Failed to fetch SonarQube report"
rm -f "${REPORT_FILE}.page"
rm -f "${REPORT_FILE}.page.array"
rm -f "${REPORT_FILE}.array"
exit 1
fi
cnt="$(jq '.issues | length' "${REPORT_FILE}.page")"
if [ "${cnt}" == "0" ] || [ "${cnt}" == "" ]; then
break
fi
jq -r '.issues' "${REPORT_FILE}.page" > "${REPORT_FILE}.page.array"
if [ -f "${REPORT_FILE}" ]; then
jq -r -s '.[0] + .[1]' "${REPORT_FILE}" "${REPORT_FILE}.page.array" > "${REPORT_FILE}.array"
mv -f "${REPORT_FILE}.array" "${REPORT_FILE}"
else
mv -f "${REPORT_FILE}.page.array" "${REPORT_FILE}"
fi
done
rm -f "${REPORT_FILE}.page"
rm -f "${REPORT_FILE}.page.array"

View File

@ -0,0 +1,74 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#!/bin/sh
set -e
if [ -z "$SONAR_HOST_URL" ]; then
SONAR_HOST_URL="http://127.0.0.1:9000"
fi
if [ -z "$SONAR_PROJECT_KEY" ]; then
echo "SONAR_PROJECT_KEY is not set"
exit 1
fi
creds="${1:-'admin:password'}"
quality_profile_name="cassandra"
quality_profile_config="${2:-.build/sonar/sonar-quality-profile.xml}"
quality_gate_name="cassandra"
quality_gate_config="${3:-.build/sonar/sonar-quality-gate.json}"
curl_cmd() {
curl -sS -u "$creds" "$@"
}
# Create project
curl_cmd -X POST "${SONAR_HOST_URL}/api/projects/create?name=${SONAR_PROJECT_KEY}&mainBranch=trunk&newCodeDefinitionType=PREVIOUS_VERSION&project=${SONAR_PROJECT_KEY}&visibility=public" 1>&2
# Setup quality profile
curl_cmd -X POST "${SONAR_HOST_URL}/api/qualityprofiles/restore" --form "backup=@${quality_profile_config}" 1>&2
curl_cmd -X POST "${SONAR_HOST_URL}/api/qualityprofiles/add_project?language=java&project=${SONAR_PROJECT_KEY}&qualityProfile=${quality_profile_name}" 1>&2
# Setup quality gate
curl_cmd -X POST "${SONAR_HOST_URL}/api/qualitygates/destroy?name=${quality_gate_name}" 1>&2 2>/dev/null || true
curl_cmd -X POST "${SONAR_HOST_URL}/api/qualitygates/create?name=${quality_gate_name}" 1>&2
for cond_id in $(curl_cmd -X GET "${SONAR_HOST_URL}/api/qualitygates/show?name=${quality_gate_name}" | jq -r '.conditions[].id')
do
curl_cmd -X POST "${SONAR_HOST_URL}/api/qualitygates/delete_condition?id=${cond_id}" 1>&2
done
for cond in $(jq -r '.conditions[] | "metric=\(.metric)&op=\(.op)&error=\(.error)"' "${quality_gate_config}")
do
curl_cmd -X POST "${SONAR_HOST_URL}/api/qualitygates/create_condition?gateName=${quality_gate_name}&${cond}" 1>&2
done
curl_cmd -X POST "${SONAR_HOST_URL}/api/qualitygates/select?gateName=${quality_gate_name}&projectKey=${SONAR_PROJECT_KEY}" 1>&2
# Setup access token
# Drop the existing access token so that we can create it once again - we need to recreate a token because it is
# impossible to read the existing token
curl_cmd -X POST "${SONAR_HOST_URL}/api/user_tokens/revoke?name=cassandra&projectKey=${SONAR_PROJECT_KEY}" 1>&2 2>/dev/null || true
# Create the access token for the project analysis
curl_cmd -X POST "${SONAR_HOST_URL}/api/user_tokens/generate?name=cassandra&type=PROJECT_ANALYSIS_TOKEN&projectKey=${SONAR_PROJECT_KEY}" | jq -r '.token'

View File

@ -29,6 +29,7 @@
<property environment="env"/>
<property file="build.properties" />
<property file="build.properties.default" />
<property file="${user.home}/.ant/build.properties"/>
<property name="debuglevel" value="source,lines,vars"/>
<!-- default version and SCM information -->
@ -534,6 +535,7 @@
<!-- Stress build file -->
<property name="stress.build.src" value="${basedir}/tools/stress/src" />
<property name="stress.build.resources" value="${basedir}/tools/stress/resources" />
<property name="stress.test.src" value="${basedir}/tools/stress/test/unit" />
<property name="stress.build.classes" value="${build.classes}/stress" />
<property name="stress.test.classes" value="${build.dir}/test/stress-classes" />
@ -566,7 +568,7 @@
</classpath>
</javac>
<copy todir="${stress.build.classes}">
<fileset dir="${stress.build.src}/resources" />
<fileset dir="${stress.build.resources}" />
</copy>
</target>
@ -2064,4 +2066,5 @@
<import file="${build.helpers.dir}/build-checkstyle.xml"/>
<import file="${build.helpers.dir}/build-cqlsh.xml"/>
<import file="${build.helpers.dir}/build-bench.xml"/>
<import file="${build.helpers.dir}/build-sonar.xml"/>
</project>

View File

@ -196,7 +196,6 @@ public class AutoSavingCache<K extends CacheKey, V> extends InstrumentingCache<K
return cacheLoad;
}
@SuppressWarnings("resource")
public int loadSaved()
{
int count = 0;

View File

@ -188,12 +188,10 @@ public class OHCProvider implements CacheProvider<RowCacheKey, IRowCacheEntry>
}
}
@SuppressWarnings("resource")
public IRowCacheEntry deserialize(ByteBuffer buf)
{
try
try (RebufferingInputStream in = new DataInputBuffer(buf, false))
{
RebufferingInputStream in = new DataInputBuffer(buf, false);
boolean isSentinel = in.readBoolean();
if (isSentinel)
return new RowCacheSentinel(in.readLong());

View File

@ -75,7 +75,6 @@ public class SerializingCache<K, V> implements ICache<K, V>
}, serializer);
}
@SuppressWarnings("resource")
private V deserialize(RefCountedMemory mem)
{
try
@ -89,7 +88,6 @@ public class SerializingCache<K, V> implements ICache<K, V>
}
}
@SuppressWarnings("resource")
private RefCountedMemory serialize(V value)
{
long serializedSize = serializer.serializedSize(value);
@ -148,7 +146,6 @@ public class SerializingCache<K, V> implements ICache<K, V>
cache.invalidateAll();
}
@SuppressWarnings("resource")
public V get(K key)
{
RefCountedMemory mem = cache.getIfPresent(key);
@ -166,7 +163,6 @@ public class SerializingCache<K, V> implements ICache<K, V>
}
}
@SuppressWarnings("resource")
public void put(K key, V value)
{
RefCountedMemory mem = serialize(value);
@ -188,7 +184,6 @@ public class SerializingCache<K, V> implements ICache<K, V>
old.unreference();
}
@SuppressWarnings("resource")
public boolean putIfAbsent(K key, V value)
{
RefCountedMemory mem = serialize(value);
@ -212,7 +207,6 @@ public class SerializingCache<K, V> implements ICache<K, V>
return old == null;
}
@SuppressWarnings("resource")
public boolean replace(K key, V oldToReplace, V value)
{
// if there is no old value in our cache, we fail
@ -256,7 +250,6 @@ public class SerializingCache<K, V> implements ICache<K, V>
public void remove(K key)
{
@SuppressWarnings("resource")
RefCountedMemory mem = cache.asMap().remove(key);
if (mem != null)
mem.unreference();

View File

@ -44,7 +44,6 @@ public class ExecutorLocals implements WithResources, Closeable
public static class Impl
{
@SuppressWarnings("resource")
protected static void set(TraceState traceState, ClientWarn.State clientWarnState)
{
if (traceState == null && clientWarnState == null) locals.set(none);
@ -79,7 +78,6 @@ public class ExecutorLocals implements WithResources, Closeable
return locals == none ? WithResources.none() : locals;
}
@SuppressWarnings("resource")
public static ExecutorLocals create(TraceState traceState)
{
ExecutorLocals current = locals.get();

View File

@ -616,7 +616,6 @@ public final class JavaBasedUDFunction extends UDFunction
return findType(result.toString());
}
@SuppressWarnings("resource")
private NameEnvironmentAnswer findType(String className)
{
if (className.equals(this.className))

View File

@ -39,7 +39,6 @@ public class CassandraKeyspaceWriteHandler implements KeyspaceWriteHandler
}
@Override
@SuppressWarnings("resource") // group is closed when CassandraWriteContext is closed
public WriteContext beginWrite(Mutation mutation, boolean makeDurable) throws RequestExecutionException
{
OpOrder.Group group = null;
@ -100,7 +99,6 @@ public class CassandraKeyspaceWriteHandler implements KeyspaceWriteHandler
return CommitLog.instance.add(mutation);
}
@SuppressWarnings("resource") // group is closed when CassandraWriteContext is closed
private WriteContext createEmptyContext()
{
OpOrder.Group group = null;

View File

@ -31,7 +31,6 @@ public class CassandraTableWriteHandler implements TableWriteHandler
}
@Override
@SuppressWarnings("resource")
public void write(PartitionUpdate update, WriteContext context, boolean updateIndexes)
{
CassandraWriteContext ctx = CassandraWriteContext.fromContext(context);

View File

@ -1294,7 +1294,6 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean, Memtable.Owner
Iterator<SSTableMultiWriter> writerIterator = flushResults.iterator();
while (writerIterator.hasNext())
{
@SuppressWarnings("resource")
SSTableMultiWriter writer = writerIterator.next();
if (writer.getBytesWritten() > 0)
{
@ -1431,7 +1430,6 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean, Memtable.Owner
* @param context write context for current update
* @param updateIndexes whether secondary indexes should be updated
*/
@SuppressWarnings("resource") // opGroup
public void apply(PartitionUpdate update, CassandraWriteContext context, boolean updateIndexes)
{
@ -1940,7 +1938,6 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean, Memtable.Owner
return nowInSec - metadata().params.gcGraceSeconds;
}
@SuppressWarnings("resource")
public RefViewFragment selectAndReference(Function<View, Iterable<SSTableReader>> filter)
{
long failingSince = -1L;
@ -2549,7 +2546,6 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean, Memtable.Owner
Supplier<Collection<Range<PartitionPosition>>> rangesSupplier,
Refs<SSTableReader> placeIntoRefs)
{
@SuppressWarnings("resource") // closed by finish or on exception
SSTableMultiWriter memtableContent = writeMemtableRanges(rangesSupplier, repairSessionID);
if (memtableContent != null)
{

View File

@ -315,7 +315,6 @@ public class PartitionRangeReadCommand extends ReadCommand implements PartitionR
}
@VisibleForTesting
@SuppressWarnings("resource")
public UnfilteredPartitionIterator queryStorage(final ColumnFamilyStore cfs, ReadExecutionController controller)
{
ColumnFamilyStore.ViewFragment view = cfs.select(View.selectLive(dataRange().keyRange()));
@ -328,7 +327,6 @@ public class PartitionRangeReadCommand extends ReadCommand implements PartitionR
SSTableReadsListener readCountUpdater = newReadCountUpdater();
for (Memtable memtable : view.memtables)
{
@SuppressWarnings("resource") // We close on exception and on closing the result returned by this method
UnfilteredPartitionIterator iter = memtable.partitionIterator(columnFilter(), dataRange(), readCountUpdater);
controller.updateMinOldestUnrepairedTombstone(memtable.getMinLocalDeletionTime());
inputCollector.addMemtableIterator(RTBoundValidator.validate(iter, RTBoundValidator.Stage.MEMTABLE, false));
@ -344,7 +342,6 @@ public class PartitionRangeReadCommand extends ReadCommand implements PartitionR
if (!intersects && !hasPartitionLevelDeletions && !hasRequiredStatics)
continue;
@SuppressWarnings("resource") // We close on exception and on closing the result returned by this method
UnfilteredPartitionIterator iter = sstable.partitionIterator(columnFilter(), dataRange(), readCountUpdater);
inputCollector.addSSTableIterator(sstable, RTBoundValidator.validate(iter, RTBoundValidator.Stage.SSTABLE, false));
@ -558,7 +555,6 @@ public class PartitionRangeReadCommand extends ReadCommand implements PartitionR
}
@Override
@SuppressWarnings("resource")
public UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController)
{
VirtualTable view = VirtualKeyspaceRegistry.instance.getTableNullable(metadata().id);

View File

@ -353,7 +353,6 @@ public class RangeTombstoneList implements Iterable<RangeTombstone>, IMeasurable
return iterator(false);
}
@SuppressWarnings("resource")
public Iterator<RangeTombstone> iterator(boolean reversed)
{
return reversed

View File

@ -340,7 +340,6 @@ public abstract class ReadCommand extends AbstractReadQuery
*/
public abstract boolean isReversed();
@SuppressWarnings("resource")
public ReadResponse createResponse(UnfilteredPartitionIterator iterator, RepairedDataInfo rdi)
{
// validate that the sequence of RT markers is correct: open is followed by close, deletion times for both
@ -352,7 +351,6 @@ public abstract class ReadCommand extends AbstractReadQuery
: ReadResponse.createDataResponse(iterator, this, rdi);
}
@SuppressWarnings("resource") // We don't need to close an empty iterator.
public ReadResponse createEmptyResponse()
{
UnfilteredPartitionIterator iterator = EmptyIterators.unfilteredPartition(metadata());
@ -400,7 +398,6 @@ public abstract class ReadCommand extends AbstractReadQuery
*
* @return an iterator over the result of executing this command locally.
*/
@SuppressWarnings("resource") // The result iterator is closed upon exceptions (we know it's fine to potentially not close the intermediary
// iterators created inside the try as long as we do close the original resultIterator), or by closing the result.
public UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController)
{
@ -851,7 +848,6 @@ public abstract class ReadCommand extends AbstractReadQuery
return toCQLString();
}
@SuppressWarnings("resource") // resultant iterators are closed by their callers
InputCollector<UnfilteredRowIterator> iteratorsForPartition(ColumnFamilyStore.ViewFragment view, ReadExecutionController controller)
{
final BiFunction<List<UnfilteredRowIterator>, RepairedDataInfo, UnfilteredRowIterator> merge =
@ -868,7 +864,6 @@ public abstract class ReadCommand extends AbstractReadQuery
return new InputCollector<>(view, controller, merge, postLimitPartitions);
}
@SuppressWarnings("resource") // resultant iterators are closed by their callers
InputCollector<UnfilteredPartitionIterator> iteratorsForRange(ColumnFamilyStore.ViewFragment view, ReadExecutionController controller)
{
final BiFunction<List<UnfilteredPartitionIterator>, RepairedDataInfo, UnfilteredPartitionIterator> merge =
@ -952,7 +947,6 @@ public abstract class ReadCommand extends AbstractReadQuery
unrepairedIters.add(iter);
}
@SuppressWarnings("resource") // the returned iterators are closed by the caller
List<T> finalizeIterators(ColumnFamilyStore cfs, long nowInSec, long oldestUnrepairedTombstone)
{
if (repairedIters.isEmpty())

View File

@ -475,7 +475,6 @@ public class SinglePartitionReadCommand extends ReadCommand implements SinglePar
metric.readLatency.addNano(latencyNanos);
}
@SuppressWarnings("resource") // we close the created iterator through closing the result of this method (and SingletonUnfilteredPartitionIterator ctor cannot fail)
protected UnfilteredPartitionIterator queryStorage(final ColumnFamilyStore cfs, ReadExecutionController executionController)
{
// skip the row cache and go directly to sstables/memtable if repaired status of
@ -495,7 +494,6 @@ public class SinglePartitionReadCommand extends ReadCommand implements SinglePar
* If the partition is is not cached, we figure out what filter is "biggest", read
* that from disk, then filter the result and either cache that or return it.
*/
@SuppressWarnings("resource")
private UnfilteredRowIterator getThroughCache(ColumnFamilyStore cfs, ReadExecutionController executionController)
{
assert !cfs.isIndex(); // CASSANDRA-5732
@ -559,7 +557,6 @@ public class SinglePartitionReadCommand extends ReadCommand implements SinglePar
final int rowsToCache = metadata().params.caching.rowsPerPartitionToCache();
final boolean enforceStrictLiveness = metadata().enforceStrictLiveness();
@SuppressWarnings("resource") // we close on exception or upon closing the result of this method
UnfilteredRowIterator iter = fullPartitionRead(metadata(), nowInSec(), partitionKey()).queryMemtableAndDisk(cfs, executionController);
try
{
@ -697,7 +694,6 @@ public class SinglePartitionReadCommand extends ReadCommand implements SinglePar
for (Memtable memtable : view.memtables)
{
@SuppressWarnings("resource") // 'iter' is added to iterators which is closed on exception, or through the closing of the final merged iterator
UnfilteredRowIterator iter = memtable.rowIterator(partitionKey(), filter.getSlices(metadata()), columnFilter(), filter.isReversed(), metricsCollector);
if (iter == null)
continue;
@ -761,7 +757,6 @@ public class SinglePartitionReadCommand extends ReadCommand implements SinglePar
controller.updateMinOldestUnrepairedTombstone(sstable.getMinLocalDeletionTime());
// 'iter' is added to iterators which is closed on exception, or through the closing of the final merged iterator
@SuppressWarnings("resource")
UnfilteredRowIterator iter = intersects ? makeRowIteratorWithLowerBound(cfs, sstable, metricsCollector)
: makeRowIteratorWithSkippedNonStaticContent(cfs, sstable, metricsCollector);
@ -779,7 +774,6 @@ public class SinglePartitionReadCommand extends ReadCommand implements SinglePar
// an iterator figure out that (see `StatsMetadata.hasPartitionLevelDeletions`)
// 'iter' is added to iterators which is closed on exception, or through the closing of the final merged iterator
@SuppressWarnings("resource")
UnfilteredRowIterator iter = makeRowIteratorWithSkippedNonStaticContent(cfs, sstable, metricsCollector);
// if the sstable contains a partition delete, then we must include it regardless of whether it
@ -877,12 +871,10 @@ public class SinglePartitionReadCommand extends ReadCommand implements SinglePar
* Note that we cannot use the Transformations framework because they greedily get the static row, which
* would cause all iterators to be initialized and hence all sstables to be accessed.
*/
@SuppressWarnings("resource")
private UnfilteredRowIterator withSSTablesIterated(List<UnfilteredRowIterator> iterators,
TableMetrics metrics,
SSTableReadMetricsCollector metricsCollector)
{
@SuppressWarnings("resource") // Closed through the closing of the result of the caller method.
UnfilteredRowIterator merged = UnfilteredRowIterators.merge(iterators);
if (!merged.isEmpty())
@ -1380,7 +1372,6 @@ public class SinglePartitionReadCommand extends ReadCommand implements SinglePar
}
@Override
@SuppressWarnings("resource")
public UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController)
{
VirtualTable view = VirtualKeyspaceRegistry.instance.getTableNullable(metadata().id);

View File

@ -116,7 +116,6 @@ public class SizeEstimatesRecorder implements SchemaChangeListener, Runnable
}
}
@SuppressWarnings("resource")
private static Map<Range<Token>, Pair<Long, Long>> computeSizeEstimates(ColumnFamilyStore table, Collection<Range<Token>> ranges)
{
// for each local primary range, estimate (crudely) mean partition size and partitions count.

View File

@ -213,7 +213,6 @@ public abstract class CommitLogSegment
* Allocate space in this buffer for the provided mutation, and return the allocated Allocation object.
* Returns null if there is not enough space in this segment, and a new segment is needed.
*/
@SuppressWarnings("resource") //we pass the op order around
Allocation allocate(Mutation mutation, int size)
{
final OpOrder.Group opGroup = appendOrder.start();

View File

@ -301,7 +301,6 @@ public class CommitLogSegmentReader implements Iterable<CommitLogSegmentReader.S
nextLogicalStart = reader.getFilePointer();
}
@SuppressWarnings("resource")
public SyncSegment nextSegment(final int startPosition, final int nextSectionStartPosition) throws IOException
{
reader.seek(startPosition);
@ -381,7 +380,6 @@ public class CommitLogSegmentReader implements Iterable<CommitLogSegmentReader.S
};
}
@SuppressWarnings("resource")
public SyncSegment nextSegment(int startPosition, int nextSectionStartPosition) throws IOException
{
int totalPlainTextLength = reader.readInt();

View File

@ -254,7 +254,6 @@ public abstract class AbstractCompactionStrategy
* allow for a more memory efficient solution if we know the sstable don't overlap (see
* LeveledCompactionStrategy for instance).
*/
@SuppressWarnings({"resource", "RedundantSuppression"})
public ScannerList getScanners(Collection<SSTableReader> sstables, Collection<Range<Token>> ranges)
{
ArrayList<ISSTableScanner> scanners = new ArrayList<>();
@ -365,7 +364,6 @@ public abstract class AbstractCompactionStrategy
for (int i=0, isize=scanners.size(); i<isize; i++)
{
@SuppressWarnings({"resource", "RedundantSuppression"})
ISSTableScanner scanner = scanners.get(i);
compressed += scanner.getCompressedLengthInBytes();
uncompressed += scanner.getLengthInBytes();

View File

@ -313,7 +313,6 @@ public class CompactionController extends AbstractCompactionController
Predicates.notNull());
}
@SuppressWarnings("resource") // caller to close
private UnfilteredRowIterator getShadowIterator(SSTableReader reader, DecoratedKey key, boolean tombstoneOnly)
{
if (reader.isMarkedSuspect() ||

View File

@ -119,7 +119,6 @@ public class CompactionIterator extends CompactionInfo.Holder implements Unfilte
this(type, scanners, controller, nowInSec, compactionId, ActiveCompactionsTracker.NOOP, null);
}
@SuppressWarnings("resource") // We make sure to close mergedIterator in close() and CompactionIterator is itself an AutoCloseable
public CompactionIterator(OperationType type,
List<ISSTableScanner> scanners,
AbstractCompactionController controller,
@ -223,7 +222,6 @@ public class CompactionIterator extends CompactionInfo.Holder implements Unfilte
int merged = 0;
for (int i=0, isize=versions.size(); i<isize; i++)
{
@SuppressWarnings("resource")
UnfilteredRowIterator iter = versions.get(i);
if (iter != null)
merged++;
@ -240,7 +238,6 @@ public class CompactionIterator extends CompactionInfo.Holder implements Unfilte
Columns regulars = Columns.NONE;
for (int i=0, isize=versions.size(); i<isize; i++)
{
@SuppressWarnings("resource")
UnfilteredRowIterator iter = versions.get(i);
if (iter != null)
{
@ -670,7 +667,6 @@ public class CompactionIterator extends CompactionInfo.Holder implements Unfilte
}
@Override
@SuppressWarnings("resource")
protected UnfilteredRowIterator applyToPartition(UnfilteredRowIterator partition)
{
currentToken = partition.partitionKey().getToken();

View File

@ -419,7 +419,6 @@ public class CompactionManager implements CompactionManagerMBean, ICompactionMan
* @param jobs the number of threads to use - 0 means use all available. It never uses more than concurrent_compactors threads
* @return status of the operation
*/
@SuppressWarnings("resource")
private AllSSTableOpStatus parallelAllSSTableOperation(final ColumnFamilyStore cfs,
final OneSSTableOperation operation,
int jobs,
@ -981,13 +980,11 @@ public class CompactionManager implements CompactionManagerMBean, ICompactionMan
FBUtilities.waitOnFutures(submitMaximal(cfStore, getDefaultGcBefore(cfStore, FBUtilities.nowInSeconds()), splitOutput));
}
@SuppressWarnings("resource") // the tasks are executed in parallel on the executor, making sure that they get closed
public List<Future<?>> submitMaximal(final ColumnFamilyStore cfStore, final long gcBefore, boolean splitOutput)
{
return submitMaximal(cfStore, gcBefore, splitOutput, OperationType.MAJOR_COMPACTION);
}
@SuppressWarnings("resource")
public List<Future<?>> submitMaximal(final ColumnFamilyStore cfStore, final long gcBefore, boolean splitOutput, OperationType operationType)
{
// here we compute the task off the compaction executor, so having that present doesn't

View File

@ -183,7 +183,6 @@ public class CompactionStrategyHolder extends AbstractStrategyHolder
}
@Override
@SuppressWarnings("resource")
public List<ISSTableScanner> getScanners(GroupedSSTableContainer sstables, Collection<Range<Token>> ranges)
{
List<ISSTableScanner> scanners = new ArrayList<>(strategies.size());

View File

@ -243,7 +243,6 @@ public class CompactionStrategyManager implements INotificationConsumer
* @return
*/
@VisibleForTesting
@SuppressWarnings("resource") // transaction is closed by AbstractCompactionTask::execute
AbstractCompactionTask findUpgradeSSTableTask()
{
if (!isEnabled() || !DatabaseDescriptor.automaticSSTableUpgrade())
@ -951,7 +950,6 @@ public class CompactionStrategyManager implements INotificationConsumer
* @param ranges
* @return
*/
@SuppressWarnings("resource")
public AbstractCompactionStrategy.ScannerList maybeGetScanners(Collection<SSTableReader> sstables, Collection<Range<Token>> ranges)
{
maybeReloadDiskBoundaries();

View File

@ -28,7 +28,6 @@ import org.apache.cassandra.utils.FBUtilities;
public class CompactionTasks extends AbstractCollection<AbstractCompactionTask> implements AutoCloseable
{
@SuppressWarnings("resource")
private static final CompactionTasks EMPTY = new CompactionTasks(Collections.emptyList());
private final Collection<AbstractCompactionTask> tasks;

View File

@ -126,7 +126,6 @@ public class LeveledCompactionStrategy extends AbstractCompactionStrategy
* the only difference between background and maximal in LCS is that maximal is still allowed
* (by explicit user request) even when compaction is disabled.
*/
@SuppressWarnings("resource") // transaction is closed by AbstractCompactionTask::execute
public AbstractCompactionTask getNextBackgroundTask(long gcBefore)
{
Collection<SSTableReader> previousCandidate = null;
@ -179,7 +178,6 @@ public class LeveledCompactionStrategy extends AbstractCompactionStrategy
}
}
@SuppressWarnings("resource") // transaction is closed by AbstractCompactionTask::execute
public synchronized Collection<AbstractCompactionTask> getMaximalTask(long gcBefore, boolean splitOutput)
{
Iterable<SSTableReader> sstables = manifest.getSSTables();
@ -195,7 +193,6 @@ public class LeveledCompactionStrategy extends AbstractCompactionStrategy
}
@Override
@SuppressWarnings("resource") // transaction is closed by AbstractCompactionTask::execute
public AbstractCompactionTask getUserDefinedTask(Collection<SSTableReader> sstables, long gcBefore)
{
@ -337,7 +334,6 @@ public class LeveledCompactionStrategy extends AbstractCompactionStrategy
Collection<SSTableReader> intersecting = LeveledScanner.intersecting(byLevel.get(level), ranges);
if (!intersecting.isEmpty())
{
@SuppressWarnings("resource") // The ScannerList will be in charge of closing (and we close properly on errors)
ISSTableScanner scanner = new LeveledScanner(cfs.metadata(), intersecting, ranges);
scanners.add(scanner);
}

View File

@ -264,7 +264,6 @@ class PendingRepairManager
return tasks;
}
@SuppressWarnings("resource")
private RepairFinishedCompactionTask getRepairFinishedCompactionTask(TimeUUID sessionID)
{
Preconditions.checkState(canCleanup(sessionID));
@ -429,7 +428,6 @@ class PendingRepairManager
return !ActiveRepairService.instance().consistent.local.isSessionInProgress(sessionID);
}
@SuppressWarnings("resource")
synchronized Set<ISSTableScanner> getScanners(Collection<SSTableReader> sstables, Collection<Range<Token>> ranges)
{
if (sstables.isEmpty())

View File

@ -175,7 +175,6 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
return sstr.getReadMeter() == null ? 0.0 : sstr.getReadMeter().twoHourRate() / sstr.estimatedKeys();
}
@SuppressWarnings("resource")
public AbstractCompactionTask getNextBackgroundTask(long gcBefore)
{
List<SSTableReader> previousCandidate = null;
@ -203,7 +202,6 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
}
}
@SuppressWarnings("resource")
public synchronized Collection<AbstractCompactionTask> getMaximalTask(final long gcBefore, boolean splitOutput)
{
Iterable<SSTableReader> filteredSSTables = filterSuspectSSTables(sstables);
@ -217,7 +215,6 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
return Arrays.<AbstractCompactionTask>asList(new CompactionTask(cfs, txn, gcBefore));
}
@SuppressWarnings("resource")
public AbstractCompactionTask getUserDefinedTask(Collection<SSTableReader> sstables, final long gcBefore)
{
assert !sstables.isEmpty(); // checked for by CM.submitUserDefined

View File

@ -80,7 +80,6 @@ public class TimeWindowCompactionStrategy extends AbstractCompactionStrategy
}
@Override
@SuppressWarnings("resource") // transaction is closed by AbstractCompactionTask::execute
public AbstractCompactionTask getNextBackgroundTask(long gcBefore)
{
List<SSTableReader> previousCandidate = null;
@ -380,7 +379,6 @@ public class TimeWindowCompactionStrategy extends AbstractCompactionStrategy
}
@Override
@SuppressWarnings("resource") // transaction is closed by AbstractCompactionTask::execute
public synchronized Collection<AbstractCompactionTask> getMaximalTask(long gcBefore, boolean splitOutput)
{
Iterable<SSTableReader> filteredSSTables = filterSuspectSSTables(sstables);
@ -407,7 +405,6 @@ public class TimeWindowCompactionStrategy extends AbstractCompactionStrategy
}
@Override
@SuppressWarnings("resource") // transaction is closed by AbstractCompactionTask::execute
public synchronized AbstractCompactionTask getUserDefinedTask(Collection<SSTableReader> sstables, long gcBefore)
{
assert !sstables.isEmpty(); // checked for by CM.submitUserDefined

View File

@ -157,7 +157,6 @@ public class UnifiedCompactionStrategy extends AbstractCompactionStrategy
List<Set<SSTableReader>> nonOverlapping = splitInNonOverlappingSets(filterSuspectSSTables(getSSTables()));
for (Set<SSTableReader> set : nonOverlapping)
{
@SuppressWarnings("resource") // closed by the returned task
LifecycleTransaction txn = cfs.getTracker().tryModify(set, OperationType.COMPACTION);
if (txn != null)
tasks.add(createCompactionTask(txn, gcBefore));
@ -194,7 +193,6 @@ public class UnifiedCompactionStrategy extends AbstractCompactionStrategy
}
@Override
@SuppressWarnings("resource") // transaction closed by the returned task
public AbstractCompactionTask getUserDefinedTask(Collection<SSTableReader> sstables, final long gcBefore)
{
assert !sstables.isEmpty(); // checked for by CM.submitUserDefined
@ -231,7 +229,6 @@ public class UnifiedCompactionStrategy extends AbstractCompactionStrategy
}
}
@SuppressWarnings("resource") // transaction closed by the returned task
private UnifiedCompactionTask createCompactionTask(CompactionPick pick, long gcBefore)
{
Preconditions.checkNotNull(pick);

View File

@ -82,7 +82,6 @@ public class ShardedCompactionWriter extends CompactionAwareWriter
}
@Override
@SuppressWarnings("resource")
protected SSTableWriter sstableWriter(Directories.DataDirectory directory, DecoratedKey nextKey)
{
if (nextKey != null)

View File

@ -223,7 +223,6 @@ public abstract class CompactionAwareWriter extends Transactional.AbstractTransa
sstableWriter.switchWriter(sstableWriter(directory, nextKey));
}
@SuppressWarnings("resource")
protected SSTableWriter sstableWriter(Directories.DataDirectory directory, DecoratedKey nextKey)
{
Descriptor descriptor = cfs.newSSTableDescriptor(getDirectories().getLocationForDisk(directory));

View File

@ -42,7 +42,6 @@ public class DefaultCompactionWriter extends CompactionAwareWriter
this(cfs, directories, txn, nonExpiredSSTables, false, 0);
}
@SuppressWarnings({ "resource", "RedundantSuppression" })
public DefaultCompactionWriter(ColumnFamilyStore cfs, Directories directories, LifecycleTransaction txn, Set<SSTableReader> nonExpiredSSTables, boolean keepOriginals, int sstableLevel)
{
super(cfs, directories, txn, nonExpiredSSTables, keepOriginals);

View File

@ -47,7 +47,6 @@ public class MajorLeveledCompactionWriter extends CompactionAwareWriter
this(cfs, directories, txn, nonExpiredSSTables, maxSSTableSize, false);
}
@SuppressWarnings({ "resource", "RedundantSuppression" })
public MajorLeveledCompactionWriter(ColumnFamilyStore cfs,
Directories directories,
LifecycleTransaction txn,

View File

@ -340,7 +340,6 @@ public abstract class RowFilter implements Iterable<RowFilter.Expression>
{
DecoratedKey pk;
@SuppressWarnings("resource")
protected BaseRowIterator<?> applyToPartition(BaseRowIterator<?> partition)
{
pk = partition.partitionKey();

View File

@ -173,14 +173,12 @@ public class LifecycleTransaction extends Transactional.AbstractTransactional im
/**
* construct an empty Transaction with no existing readers
*/
@SuppressWarnings("resource") // log closed during postCleanup
public static LifecycleTransaction offline(OperationType operationType)
{
Tracker dummy = Tracker.newDummyTracker();
return new LifecycleTransaction(dummy, new LogTransaction(operationType, dummy), Collections.emptyList());
}
@SuppressWarnings("resource") // log closed during postCleanup
LifecycleTransaction(Tracker tracker, OperationType operationType, Iterable<? extends SSTableReader> readers)
{
this(tracker, new LogTransaction(operationType, tracker), readers);

View File

@ -83,7 +83,6 @@ public class LogReplicaSet implements AutoCloseable
try
{
@SuppressWarnings("resource") // LogReplicas are closed in LogReplicaSet::close
final LogReplica replica = LogReplica.create(directory, fileName);
records.forEach(replica::append);
replicasByFile.put(directory, replica);

View File

@ -95,7 +95,6 @@ public class Flushing
}
}
@SuppressWarnings("resource") // writer owned by runnable, to be closed or aborted by its caller
static FlushRunnable flushRunnable(ColumnFamilyStore cfs,
Memtable memtable,
PartitionPosition from,

View File

@ -31,7 +31,6 @@ public abstract class PartitionIterators
{
private PartitionIterators() {}
@SuppressWarnings("resource") // The created resources are returned right away
public static RowIterator getOnlyElement(final PartitionIterator iter, SinglePartitionReadQuery query)
{
// If the query has no results, we'll get an empty iterator, but we still
@ -58,7 +57,6 @@ public abstract class PartitionIterators
return Transformation.apply(toReturn, new Close());
}
@SuppressWarnings("resource") // The created resources are returned right away
public static PartitionIterator concat(final List<PartitionIterator> iterators)
{
if (iterators.size() == 1)
@ -116,7 +114,6 @@ public abstract class PartitionIterators
* Note that this is only meant for debugging as this can log a very large amount of
* logging at INFO.
*/
@SuppressWarnings("resource") // The created resources are returned right away
public static PartitionIterator loggingIterator(PartitionIterator iterator, final String id)
{
class Logger extends Transformation<RowIterator>

View File

@ -186,7 +186,6 @@ public class PartitionUpdate extends AbstractBTreePartition
* Warning: this method does not close the provided iterator, it is up to
* the caller to close it.
*/
@SuppressWarnings("resource")
public static PartitionUpdate fromIterator(UnfilteredRowIterator iterator, ColumnFilter filter)
{
iterator = UnfilteredRowIterators.withOnlyQueriedData(iterator, filter);
@ -206,7 +205,6 @@ public class PartitionUpdate extends AbstractBTreePartition
* Warning: this method does not close the provided iterator, it is up to
* the caller to close it.
*/
@SuppressWarnings("resource")
public static PartitionUpdate fromIterator(RowIterator iterator, ColumnFilter filter)
{
iterator = RowIterators.withOnlyQueriedData(iterator, filter);
@ -242,7 +240,6 @@ public class PartitionUpdate extends AbstractBTreePartition
*
* @return the deserialized update or {@code null} if {@code bytes == null}.
*/
@SuppressWarnings("resource")
public static PartitionUpdate fromBytes(ByteBuffer bytes, int version)
{
if (bytes == null)

View File

@ -74,7 +74,6 @@ public abstract class PurgeFunction extends Transformation<UnfilteredRowIterator
}
@Override
@SuppressWarnings("resource")
protected UnfilteredRowIterator applyToPartition(UnfilteredRowIterator partition)
{
onNewPartition(partition.partitionKey());

View File

@ -71,7 +71,6 @@ public abstract class UnfilteredPartitionIterators
};
}
@SuppressWarnings("resource") // The created resources are returned right away
public static UnfilteredRowIterator getOnlyElement(final UnfilteredPartitionIterator iter, SinglePartitionReadCommand command)
{
// If the query has no results, we'll get an empty iterator, but we still
@ -121,7 +120,6 @@ public abstract class UnfilteredPartitionIterators
return FilteredPartitions.filter(iterator, nowInSec);
}
@SuppressWarnings("resource")
public static UnfilteredPartitionIterator merge(final List<? extends UnfilteredPartitionIterator> iterators, final MergeListener listener)
{
assert !iterators.isEmpty();
@ -154,7 +152,6 @@ public abstract class UnfilteredPartitionIterators
}
}
@SuppressWarnings("resource")
protected UnfilteredRowIterator getReduced()
{
UnfilteredRowIterators.MergeListener rowListener = listener == null
@ -220,7 +217,6 @@ public abstract class UnfilteredPartitionIterators
};
}
@SuppressWarnings("resource")
public static UnfilteredPartitionIterator mergeLazily(final List<? extends UnfilteredPartitionIterator> iterators)
{
assert !iterators.isEmpty();

View File

@ -189,7 +189,6 @@ public class PendingAntiCompaction
this.acquireSleepMillis = acquireSleepMillis;
}
@SuppressWarnings("resource")
private AcquireResult acquireTuple()
{
// this method runs with compactions stopped & disabled

View File

@ -727,7 +727,6 @@ public interface Row extends Unfiltered, Iterable<ColumnData>, IMeasurableMemory
lastRowSet = i;
}
@SuppressWarnings("resource")
public Row merge(DeletionTime activeDeletion)
{
// If for this clustering we have only one row version and have no activeDeletion (i.e. nothing to filter out),
@ -836,7 +835,6 @@ public interface Row extends Unfiltered, Iterable<ColumnData>, IMeasurableMemory
return ColumnMetadataVersionComparator.INSTANCE.compare(column, dataColumn) < 0;
}
@SuppressWarnings("resource")
protected ColumnData getReduced()
{
if (column.isSimple())

View File

@ -123,7 +123,6 @@ public abstract class Rows
* @param merged the result of merging {@code inputs}.
* @param inputs the inputs whose merge yielded {@code merged}.
*/
@SuppressWarnings("resource")
public static void diff(RowDiffListener diffListener, Row merged, Row...inputs)
{
Clustering<?> clustering = merged.clustering();

View File

@ -118,7 +118,6 @@ public class UnfilteredRowIteratorWithLowerBound extends LazilyInitializedUnfilt
@Override
protected UnfilteredRowIterator initializeIterator()
{
@SuppressWarnings("resource") // 'iter' is added to iterators which is closed on exception, or through the closing of the final merged iterator
UnfilteredRowIterator iter = RTBoundValidator.validate(sstable.rowIterator(partitionKey(), slices, selectedColumns, isReverseOrder, listener),
RTBoundValidator.Stage.SSTABLE, false);
return iter;

View File

@ -451,7 +451,6 @@ public abstract class UnfilteredRowIterators
}
}
@SuppressWarnings("resource") // We're not really creating any resource here
private static void checkForInvalidInput(List<UnfilteredRowIterator> iterators)
{
if (iterators.isEmpty())
@ -467,7 +466,6 @@ public abstract class UnfilteredRowIterators
}
}
@SuppressWarnings("resource") // We're not really creating any resource here
private static DeletionTime collectPartitionLevelDeletion(List<UnfilteredRowIterator> iterators, MergeListener listener)
{
DeletionTime[] versions = listener == null ? null : new DeletionTime[iterators.size()];

View File

@ -53,7 +53,6 @@ public class CassandraCompressedStreamReader extends CassandraStreamReader
* @throws java.io.IOException if reading the remote sstable fails. Will throw an RTE if local write fails.
*/
@Override
@SuppressWarnings("resource") // input needs to remain open, streams on top of it can't be closed
public SSTableMultiWriter read(DataInputPlus inputPlus) throws Throwable
{
long totalSize = totalSize();

View File

@ -82,7 +82,6 @@ public class CassandraEntireSSTableStreamReader implements IStreamReader
* @return SSTable transferred
* @throws IOException if reading the remote sstable fails. Will throw an RTE if local write fails.
*/
@SuppressWarnings("resource") // input needs to remain open, streams on top of it can't be closed
@Override
public SSTableMultiWriter read(DataInputPlus in) throws IOException
{
@ -168,7 +167,6 @@ public class CassandraEntireSSTableStreamReader implements IStreamReader
return dir;
}
@SuppressWarnings("resource")
protected SSTableZeroCopyWriter createWriter(ColumnFamilyStore cfs, long totalSize, Collection<Component> components) throws IOException
{
File dataDir = getDataDir(cfs, totalSize);

View File

@ -88,7 +88,6 @@ public class CassandraEntireSSTableStreamWriter
component,
prettyPrintMemory(length));
@SuppressWarnings("resource") // this is closed after the file is transferred by AsyncChannelOutputPlus
FileChannel channel = context.channel(sstable.descriptor, component, length);
long bytesWritten = out.writeFileToChannel(channel, limiter);
progress += bytesWritten;

View File

@ -82,7 +82,6 @@ public class CassandraStreamManager implements TableStreamManager
return new CassandraStreamReceiver(cfs, session, totalStreams);
}
@SuppressWarnings("resource") // references placed onto returned collection or closed on error
@Override
public Collection<OutgoingStream> createOutgoingStreams(StreamSession session, RangesAtEndpoint replicas, TimeUUID pendingRepair, PreviewKind previewKind)
{

View File

@ -102,7 +102,6 @@ public class CassandraStreamReader implements IStreamReader
* @return SSTable transferred
* @throws IOException if reading the remote sstable fails. Will throw an RTE if local write fails.
*/
@SuppressWarnings("resource") // input needs to remain open, streams on top of it can't be closed
@Override
public SSTableMultiWriter read(DataInputPlus inputPlus) throws Throwable
{
@ -154,7 +153,6 @@ public class CassandraStreamReader implements IStreamReader
{
return header != null? header.toHeader(metadata) : null; //pre-3.0 sstable have no SerializationHeader
}
@SuppressWarnings("resource")
protected SSTableMultiWriter createWriter(ColumnFamilyStore cfs, long totalSize, long repairedAt, TimeUUID pendingRepair, SSTableFormat<?, ?> format) throws IOException
{
Directories.DataDirectory localDir = cfs.getDirectories().getWriteableLocation(totalSize);

View File

@ -99,7 +99,6 @@ public class CassandraStreamReceiver implements StreamReceiver
}
@Override
@SuppressWarnings("resource")
public synchronized void received(IncomingStream stream)
{
CassandraIncomingFile file = getFile(stream);

View File

@ -75,7 +75,6 @@ implements BasePartitionIterator<R>
return fail;
}
@SuppressWarnings("resource")
public final boolean hasNext()
{
BaseRowIterator<?> next = null;

View File

@ -35,7 +35,6 @@ public final class Filter extends Transformation
}
@Override
@SuppressWarnings("resource")
protected RowIterator applyToPartition(BaseRowIterator iterator)
{
return iterator instanceof UnfilteredRows

View File

@ -50,14 +50,12 @@ public final class FilteredPartitions extends BasePartitions<RowIterator, BasePa
/**
* Filter any RangeTombstoneMarker from the iterator's iterators, transforming it into a PartitionIterator.
*/
@SuppressWarnings("resource")
public static FilteredPartitions filter(UnfilteredPartitionIterator iterator, long nowInSecs)
{
FilteredPartitions filtered = filter(iterator, new Filter(nowInSecs, iterator.metadata().enforceStrictLiveness()));
return (FilteredPartitions) Transformation.apply(filtered, new EmptyPartitionsDiscarder());
}
@SuppressWarnings("resource")
public static FilteredPartitions filter(UnfilteredPartitionIterator iterator, Filter filter)
{
return iterator instanceof UnfilteredPartitions

View File

@ -89,7 +89,6 @@ public class ViewBuilderTask extends CompactionInfo.Holder implements Callable<L
this.keysBuilt = keysBuilt;
}
@SuppressWarnings("resource")
private void buildKey(DecoratedKey key)
{
ReadQuery selectQuery = view.getReadQuery();

View File

@ -75,7 +75,6 @@ public abstract class AbstractVirtualTable implements VirtualTable
}
@Override
@SuppressWarnings("resource")
public final UnfilteredPartitionIterator select(DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter, ColumnFilter columnFilter)
{
Partition partition = data(partitionKey).getPartition(partitionKey);

View File

@ -70,7 +70,6 @@ public class ChecksummedDataInput extends RebufferingInputStream
this(channel, BufferType.OFF_HEAP);
}
@SuppressWarnings("resource")
public static ChecksummedDataInput open(File file)
{
ChannelProxy channel = new ChannelProxy(file);

View File

@ -158,7 +158,6 @@ public final class CompressedChecksummedDataInput extends ChecksummedDataInput
super.close();
}
@SuppressWarnings("resource") // Closing the ChecksummedDataInput will close the underlying channel.
public static ChecksummedDataInput upgradeInput(ChecksummedDataInput input, ICompressor compressor)
{
long position = input.getPosition();

View File

@ -132,7 +132,6 @@ public class EncryptedChecksummedDataInput extends ChecksummedDataInput
}
}
@SuppressWarnings("resource")
public static ChecksummedDataInput upgradeInput(ChecksummedDataInput input, Cipher cipher, ICompressor compressor)
{
long position = input.getPosition();

View File

@ -160,7 +160,6 @@ final class HintsBuffer
earliestHintByHost.remove(hostId);
}
@SuppressWarnings("resource")
Allocation allocate(int hintSize)
{
int totalSize = hintSize + ENTRY_OVERHEAD_SIZE;

View File

@ -72,7 +72,6 @@ class HintsReader implements AutoCloseable, Iterable<HintsReader.Page>
this.rateLimiter = rateLimiter;
}
@SuppressWarnings("resource") // HintsReader owns input
static HintsReader open(File file, RateLimiter rateLimiter)
{
ChecksummedDataInput reader = ChecksummedDataInput.open(file);
@ -148,7 +147,6 @@ class HintsReader implements AutoCloseable, Iterable<HintsReader.Page>
final class PagesIterator extends AbstractIterator<Page>
{
@SuppressWarnings("resource")
protected Page computeNext()
{
input.tryUncacheRead();

View File

@ -255,7 +255,6 @@ final class HintsWriteExecutor
}
}
@SuppressWarnings("resource") // writer not closed here
private void flushInternal(Iterator<ByteBuffer> iterator, HintsStore store)
{
long maxHintsFileSize = DatabaseDescriptor.getMaxHintsFileSize();

View File

@ -65,7 +65,6 @@ class HintsWriter implements AutoCloseable
this.globalCRC = globalCRC;
}
@SuppressWarnings("resource") // HintsWriter owns channel
static HintsWriter create(File directory, HintsDescriptor descriptor) throws IOException
{
File file = descriptor.file(directory);

View File

@ -194,7 +194,6 @@ public interface Index
*/
public static class CollatedViewIndexBuildingSupport implements IndexBuildingSupport
{
@SuppressWarnings({"resource", "RedundantSuppression"})
public SecondaryIndexBuilder getIndexBuildTask(ColumnFamilyStore cfs, Set<Index> indexes, Collection<SSTableReader> sstables, boolean isFullRebuild)
{
return new CollatedViewIndexBuilder(cfs, indexes, new ReducingKeyIterator(sstables), sstables);

View File

@ -676,7 +676,6 @@ public abstract class CassandraIndex implements Index
};
}
@SuppressWarnings("resource")
private void buildBlocking()
{
baseCfs.forceBlockingFlush(ColumnFamilyStore.FlushReason.INDEX_BUILD_STARTED);

View File

@ -60,7 +60,6 @@ public abstract class CassandraIndexSearcher implements Index.Searcher
return command;
}
@SuppressWarnings("resource") // Both the OpOrder and 'indexIter' are closed on exception, or through the closing of the result
// of this method.
public UnfilteredPartitionIterator search(ReadExecutionController executionController)
{

View File

@ -162,7 +162,6 @@ public class CompositesSearcher extends CassandraIndexSearcher
null);
}
@SuppressWarnings("resource") // We close right away if empty, and if it's assign to next it will be called either
// by the next caller of next, or through closing this iterator is this come before.
UnfilteredRowIterator dataIter =
filterStaleEntries(dataCmd.queryMemtableAndDisk(index.baseCfs, executionController),
@ -206,7 +205,6 @@ public class CompositesSearcher extends CassandraIndexSearcher
}
// We assume all rows in dataIter belong to the same partition.
@SuppressWarnings("resource")
private UnfilteredRowIterator filterStaleEntries(UnfilteredRowIterator dataIter,
final ByteBuffer indexValue,
final List<IndexEntry> entries,

View File

@ -93,7 +93,6 @@ public class KeysSearcher extends CassandraIndexSearcher
command.clusteringIndexFilter(key),
null);
@SuppressWarnings("resource") // filterIfStale closes it's iterator if either it materialize it or if it returns null.
// Otherwise, we close right away if empty, and if it's assigned to next it will be called either
// by the next caller of next, or through closing this iterator is this come before.
UnfilteredRowIterator dataIter = filterIfStale(dataCmd.queryMemtableAndDisk(index.baseCfs, executionController),

View File

@ -63,7 +63,6 @@ public class SSTableContext extends SharedCloseableImpl
this.primaryKeyMapFactory = copy.primaryKeyMapFactory;
}
@SuppressWarnings({"resource", "RedundantSuppression"})
public static SSTableContext create(SSTableReader sstable)
{
Ref<? extends SSTableReader> sstableRef = null;

View File

@ -58,7 +58,6 @@ public class IndexSearchResultIterator extends KeyRangeIterator
* Builds a new {@link IndexSearchResultIterator} that wraps a {@link KeyRangeUnionIterator} over the
* results of searching the {@link org.apache.cassandra.index.sai.memory.MemtableIndex} and the {@link SSTableIndex}es.
*/
@SuppressWarnings({"resource", "RedundantSuppression"})
public static IndexSearchResultIterator build(Expression expression,
Collection<SSTableIndex> sstableIndexes,
AbstractBounds<PartitionPosition> keyRange,

View File

@ -57,7 +57,6 @@ public class IndexFileUtils
this.writerOption = writerOption;
}
@SuppressWarnings({"resource", "RedundantSuppression"})
public IndexOutputWriter openOutput(File file)
{
assert writerOption.finishOnClose() : "IndexOutputWriter relies on close() to sync with disk.";
@ -81,7 +80,6 @@ public class IndexFileUtils
return IndexInputReader.create(handle);
}
@SuppressWarnings({"resource", "RedundantSuppression"})
public IndexInput openBlockingInput(File file)
{
FileHandle fileHandle = new FileHandle.Builder(file).complete();

View File

@ -58,7 +58,6 @@ public class IndexInputReader extends IndexInput
return new IndexInputReader(input, doOnClose);
}
@SuppressWarnings({"resource", "RedundantSuppression"})
public static IndexInputReader create(FileHandle handle)
{
RandomAccessReader reader = handle.createReader();

View File

@ -72,7 +72,6 @@ public class PerColumnIndexFiles implements Closeable
return getFile(IndexComponent.COMPRESSED_VECTORS);
}
@SuppressWarnings({"resource", "RedundantSuppression"})
private FileHandle getFile(IndexComponent indexComponent)
{
FileHandle file = files.get(indexComponent);

View File

@ -48,7 +48,6 @@ public class SSTableComponentsWriter implements PerSSTableIndexWriter
private long partitionId = -1;
@SuppressWarnings({"resource", "RedundantSuppression"})
public SSTableComponentsWriter(IndexDescriptor indexDescriptor) throws IOException
{
this.indexDescriptor = indexDescriptor;

View File

@ -98,7 +98,7 @@ public class SkinnyPrimaryKeyMap implements PrimaryKeyMap
}
@Override
@SuppressWarnings({"resource", "RedundantSuppression"})
@SuppressWarnings({"resource", "RedundantSuppression"}) // rowIdToToken, rowIdToPartitionId and cursor are closed by the SkinnyPrimaryKeyMap#close method
public PrimaryKeyMap newPerSSTablePrimaryKeyMap() throws IOException
{
LongArray rowIdToToken = new LongArray.DeferredLongArray(tokenReaderFactory::open);

View File

@ -82,7 +82,7 @@ public class WidePrimaryKeyMap extends SkinnyPrimaryKeyMap
}
@Override
@SuppressWarnings({ "resource", "RedundantSuppression" })
@SuppressWarnings({ "resource", "RedundantSuppression" }) // deferred long arrays and cursors are closed in the WidePrimaryKeyMap#close method
public PrimaryKeyMap newPerSSTablePrimaryKeyMap() throws IOException
{
LongArray rowIdToToken = new LongArray.DeferredLongArray(tokenReaderFactory::open);

View File

@ -98,7 +98,6 @@ public class BlockBalancedTreeReader extends BlockBalancedTreeWalker implements
FileUtils.closeQuietly(postingsFile);
}
@SuppressWarnings({"resource", "RedundantSuppression"})
public PostingList intersect(IntersectVisitor visitor, QueryEventListener.BalancedTreeEventListener listener, QueryContext context)
{
Relation relation = visitor.compare(minPackedValue, maxPackedValue);
@ -229,7 +228,6 @@ public class BlockBalancedTreeReader extends BlockBalancedTreeWalker implements
state.pop();
}
@SuppressWarnings({"resource", "RedundantSuppression"})
private PeekablePostingList initPostingReader(long offset) throws IOException
{
final PostingsReader.BlocksSummary summary = new PostingsReader.BlocksSummary(postingsSummaryInput, offset);
@ -336,7 +334,6 @@ public class BlockBalancedTreeReader extends BlockBalancedTreeWalker implements
state.pop();
}
@SuppressWarnings({"resource", "RedundantSuppression"})
private PeekablePostingList initFilteringPostingReader(long offset, FixedBitSet filter) throws IOException
{
final PostingsReader.BlocksSummary summary = new PostingsReader.BlocksSummary(postingsSummaryInput, offset);

View File

@ -96,7 +96,6 @@ public class BlockPackedReader implements LongArray.Factory
}
@Override
@SuppressWarnings({"resource", "RedundantSuppression"})
public LongArray open()
{
IndexInput indexInput = IndexFileUtils.instance.openInput(file);

View File

@ -82,7 +82,6 @@ public class MonotonicBlockPackedReader implements LongArray.Factory
}
@Override
@SuppressWarnings({"resource", "RedundantSuppression"})
public LongArray open()
{
final IndexInput indexInput = IndexFileUtils.instance.openInput(file);

View File

@ -96,7 +96,6 @@ public class MergePostingList implements PostingList
return maximum;
}
@SuppressWarnings({ "resource", "RedundantSuppression"})
@Override
public long nextPosting() throws IOException
{
@ -126,7 +125,6 @@ public class MergePostingList implements PostingList
return PostingList.END_OF_STREAM;
}
@SuppressWarnings({"resource", "RedundantSuppression"})
@Override
public long advance(long targetRowID) throws IOException
{

View File

@ -56,7 +56,6 @@ public abstract class IndexSegmentSearcher implements SegmentOrdering, Closeable
this.indexContext = indexContext;
}
@SuppressWarnings({"resource", "RedundantSuppression"})
public static IndexSegmentSearcher open(PrimaryKeyMap.Factory primaryKeyMapFactory,
PerColumnIndexFiles indexFiles,
SegmentMetadata segmentMetadata,

View File

@ -79,7 +79,6 @@ public class LiteralIndexSegmentSearcher extends IndexSegmentSearcher
}
@Override
@SuppressWarnings({"resource", "RedundantSuppression"})
public KeyRangeIterator search(Expression expression, AbstractBounds<PartitionPosition> keyRange, QueryContext queryContext) throws IOException
{
if (logger.isTraceEnabled())

View File

@ -79,7 +79,6 @@ public class NumericIndexSegmentSearcher extends IndexSegmentSearcher
}
@Override
@SuppressWarnings({"resource", "RedundantSuppression"})
public KeyRangeIterator search(Expression exp, AbstractBounds<PartitionPosition> keyRange, QueryContext context) throws IOException
{
if (logger.isTraceEnabled())

View File

@ -133,7 +133,6 @@ public class SegmentMetadata
return Math.toIntExact(sstableRowId - rowIdOffset);
}
@SuppressWarnings({"resource", "RedundantSuppression"})
public static List<SegmentMetadata> load(MetadataSource source, PrimaryKey.Factory primaryKeyFactory) throws IOException
{
DataInput input = source.get(NAME);

View File

@ -53,7 +53,6 @@ public class KeyRangeConcatIterator extends KeyRangeIterator
}
@Override
@SuppressWarnings({"resource", "RedundantSuppression"})
protected void performSkipTo(PrimaryKey nextKey)
{
while (!ranges.isEmpty())
@ -80,7 +79,6 @@ public class KeyRangeConcatIterator extends KeyRangeIterator
}
@Override
@SuppressWarnings({"resource", "RedundantSuppression"})
protected PrimaryKey computeNext()
{
while (!ranges.isEmpty())

View File

@ -36,7 +36,6 @@ import org.apache.cassandra.tracing.Tracing;
* initially sorting the ranges. This implementation also supports an intersection limit which limits
* the number of ranges that will be included in the intersection. This currently defaults to 2.
*/
@SuppressWarnings({"resource", "RedundantSuppression"})
public class KeyRangeIntersectionIterator extends KeyRangeIterator
{
private static final Logger logger = LoggerFactory.getLogger(KeyRangeIntersectionIterator.class);

View File

@ -28,7 +28,6 @@ import org.apache.cassandra.io.util.FileUtils;
/**
* Range Union Iterator is used to return sorted stream of elements from multiple RangeIterator instances.
*/
@SuppressWarnings({"resource", "RedundantSuppression"})
public class KeyRangeUnionIterator extends KeyRangeIterator
{
private final List<KeyRangeIterator> ranges;

View File

@ -203,7 +203,6 @@ public class QueryController
{
for (Pair<Expression, Collection<SSTableIndex>> queryViewPair : queryView.view)
{
@SuppressWarnings({"resource", "RedundantSuppression"}) // RangeIterators are closed by releaseIndexes
KeyRangeIterator indexIterator = IndexSearchResultIterator.build(queryViewPair.left, queryViewPair.right, mergeRange, queryContext);
builder.add(indexIterator);

View File

@ -160,7 +160,6 @@ public class StorageAttachedIndexSearcher implements Index.Searcher
}
@Override
@SuppressWarnings({"resource", "RedundantSuppression"}) // The iterator produced here has a nop close operation
public UnfilteredRowIterator computeNext()
{
// IMPORTANT: The correctness of the entire query pipeline relies on the fact that we consume a token
@ -478,7 +477,6 @@ public class StorageAttachedIndexSearcher implements Index.Searcher
* Used by {@link StorageAttachedIndexSearcher#filterReplicaFilteringProtection} to filter rows for columns that
* have transformations so won't get handled correctly by the row filter.
*/
@SuppressWarnings({"resource", "RedundantSuppression"})
private static PartitionIterator applyIndexFilter(PartitionIterator response, FilterTree tree, QueryContext queryContext)
{
return new PartitionIterator()

View File

@ -76,7 +76,6 @@ public class TermIterator extends RangeIterator<Long, Token>
this.referencedIndexes = referencedIndexes;
}
@SuppressWarnings("resource")
public static TermIterator build(final Expression e, Set<SSTableIndex> perSSTableIndexes)
{
final List<RangeIterator<Long, Token>> tokens = new CopyOnWriteArrayList<>();

View File

@ -81,7 +81,6 @@ public abstract class OnDiskBlock<T extends Term>
return new SearchResult<>(element, cmp, middle);
}
@SuppressWarnings("resource")
protected T getTerm(int index)
{
MappedBuffer dup = blockIndex.duplicate();

View File

@ -125,7 +125,6 @@ public class OnDiskIndex implements Iterable<OnDiskIndex.DataTerm>, Closeable
protected final ByteBuffer minTerm, maxTerm, minKey, maxKey;
@SuppressWarnings("resource")
public OnDiskIndex(File index, AbstractType<?> cmp, Function<Long, DecoratedKey> keyReader)
{
keyFetcher = keyReader;
@ -277,7 +276,6 @@ public class OnDiskIndex implements Iterable<OnDiskIndex.DataTerm>, Closeable
RangeUnionIterator.Builder<Long, Token> builder = RangeUnionIterator.builder();
for (Expression e : ranges)
{
@SuppressWarnings("resource")
RangeIterator<Long, Token> range = searchRange(e);
if (range != null)
builder.add(range);

Some files were not shown because too many files have changed in this diff Show More