From b30c00753a2c0e6c6d63ba27e566e296d281abfe Mon Sep 17 00:00:00 2001 From: Andrei Selkin Date: Sun, 31 Jan 2016 20:57:02 +0300 Subject: [PATCH] Pull #2859: Disallow usage of java.util.Stack and java.util.Vector in code --- config/checkstyle_sevntu_checks.xml | 6 ++++-- .../checks/indentation/CommentsIndentationCheck.java | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config/checkstyle_sevntu_checks.xml b/config/checkstyle_sevntu_checks.xml index 5d40780d8..f56a0a96d 100644 --- a/config/checkstyle_sevntu_checks.xml +++ b/config/checkstyle_sevntu_checks.xml @@ -28,7 +28,9 @@ - + + + @@ -89,7 +91,7 @@ - + diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheck.java index 5224acc5b..61f7eb64a 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheck.java @@ -19,8 +19,9 @@ package com.puppycrawl.tools.checkstyle.checks.indentation; +import java.util.ArrayDeque; +import java.util.Deque; import java.util.Locale; -import java.util.Stack; import org.apache.commons.lang3.ArrayUtils; @@ -497,11 +498,11 @@ public class CommentsIndentationCheck extends Check { */ private static DetailAST getOneLinePreviousStatementOfSingleLineComment(DetailAST comment) { DetailAST previousStatement = null; - final Stack stack = new Stack<>(); + final Deque stack = new ArrayDeque<>(); DetailAST root = comment.getParent(); - while (root != null || !stack.empty()) { - if (!stack.empty()) { + while (root != null || !stack.isEmpty()) { + if (!stack.isEmpty()) { root = stack.pop(); } while (root != null) {