kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gwens...@apache.org
Subject [kafka] branch 2.7 updated: MINOR internal KIP-629 changes to methods and variables
Date Tue, 13 Oct 2020 21:55:31 GMT
This is an automated email from the ASF dual-hosted git repository.

gwenshap pushed a commit to branch 2.7
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/2.7 by this push:
     new 608b784  MINOR internal KIP-629 changes to methods and variables
608b784 is described below

commit 608b7847a9df8a1ce445b7a03b7114bbf9a88f75
Author: Xavier Léauté <xvrl@apache.org>
AuthorDate: Tue Oct 13 14:52:04 2020 -0700

    MINOR internal KIP-629 changes to methods and variables
    
    cc gwenshap
    
    Author: Xavier Léauté <xvrl@apache.org>
    
    Reviewers: Gwen Shapira
    
    Closes #9405 from xvrl/minor-kip-629-vars
    
    (cherry picked from commit 26e9058aa0426102117aa00f1bbb41fae66ff4ed)
    Signed-off-by: Gwen Shapira <cshapi@gmail.com>
---
 .../kafka/connect/runtime/isolation/PluginUtils.java |  8 ++++----
 .../kafka/connect/util/SafeObjectInputStream.java    |  4 ++--
 .../runtime/isolation/DelegatingClassLoaderTest.java |  2 +-
 core/src/main/scala/kafka/tools/JmxTool.scala        | 20 ++++++++++----------
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginUtils.java
b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginUtils.java
index 0e7b762..8b21e73 100644
--- a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginUtils.java
+++ b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginUtils.java
@@ -44,7 +44,7 @@ public class PluginUtils {
     private static final Logger log = LoggerFactory.getLogger(PluginUtils.class);
 
     // Be specific about javax packages and exclude those existing in Java SE and Java EE
libraries.
-    private static final Pattern BLACKLIST = Pattern.compile("^(?:"
+    private static final Pattern EXCLUDE = Pattern.compile("^(?:"
             + "java"
             + "|javax\\.accessibility"
             + "|javax\\.activation"
@@ -125,9 +125,9 @@ public class PluginUtils {
 
     // If the base interface or class that will be used to identify Connect plugins resides
within
     // the same java package as the plugins that need to be loaded in isolation (and thus
are
-    // added to the WHITELIST), then this base interface or class needs to be excluded in
the
+    // added to the INCLUDE pattern), then this base interface or class needs to be excluded
in the
     // regular expression pattern
-    private static final Pattern WHITELIST = Pattern.compile("^org\\.apache\\.kafka\\.(?:connect\\.(?:"
+    private static final Pattern INCLUDE = Pattern.compile("^org\\.apache\\.kafka\\.(?:connect\\.(?:"
             + "transforms\\.(?!Transformation|predicates\\.Predicate$).*"
             + "|json\\..*"
             + "|file\\..*"
@@ -158,7 +158,7 @@ public class PluginUtils {
      * @return true if this class should be loaded in isolation, false otherwise.
      */
     public static boolean shouldLoadInIsolation(String name) {
-        return !(BLACKLIST.matcher(name).matches() && !WHITELIST.matcher(name).matches());
+        return !(EXCLUDE.matcher(name).matches() && !INCLUDE.matcher(name).matches());
     }
 
     /**
diff --git a/connect/runtime/src/main/java/org/apache/kafka/connect/util/SafeObjectInputStream.java
b/connect/runtime/src/main/java/org/apache/kafka/connect/util/SafeObjectInputStream.java
index b5c4c25..0ad3889 100644
--- a/connect/runtime/src/main/java/org/apache/kafka/connect/util/SafeObjectInputStream.java
+++ b/connect/runtime/src/main/java/org/apache/kafka/connect/util/SafeObjectInputStream.java
@@ -52,14 +52,14 @@ public class SafeObjectInputStream extends ObjectInputStream {
     protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException
{
         String name = desc.getName();
 
-        if (isBlacklisted(name)) {
+        if (isBlocked(name)) {
             throw new SecurityException("Illegal type to deserialize: prevented for security
reasons");
         }
 
         return super.resolveClass(desc);
     }
 
-    private boolean isBlacklisted(String name) {
+    private boolean isBlocked(String name) {
         for (String list : DEFAULT_NO_DESERIALIZE_CLASS_NAMES) {
             if (name.endsWith(list)) {
                 return true;
diff --git a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/DelegatingClassLoaderTest.java
b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/DelegatingClassLoaderTest.java
index c7426ca..757a437 100644
--- a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/DelegatingClassLoaderTest.java
+++ b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/DelegatingClassLoaderTest.java
@@ -36,7 +36,7 @@ public class DelegatingClassLoaderTest {
     public TemporaryFolder pluginDir = new TemporaryFolder();
 
     @Test
-    public void testWhiteListedManifestResources() {
+    public void testPermittedManifestResources() {
         assertTrue(
             DelegatingClassLoader.serviceLoaderManifestForPlugin("META-INF/services/org.apache.kafka.connect.rest.ConnectRestExtension"));
         assertTrue(
diff --git a/core/src/main/scala/kafka/tools/JmxTool.scala b/core/src/main/scala/kafka/tools/JmxTool.scala
index b696a12..f7ace83 100644
--- a/core/src/main/scala/kafka/tools/JmxTool.scala
+++ b/core/src/main/scala/kafka/tools/JmxTool.scala
@@ -51,7 +51,7 @@ object JmxTool extends Logging {
         .describedAs("name")
         .ofType(classOf[String])
     val attributesOpt =
-      parser.accepts("attributes", "The whitelist of attributes to query. This is a comma-separated
list. If no " +
+      parser.accepts("attributes", "The list of attributes to include in the query. This
is a comma-separated list. If no " +
         "attributes are specified all objects will be queried.")
         .withRequiredArg
         .describedAs("name")
@@ -111,8 +111,8 @@ object JmxTool extends Logging {
     val url = new JMXServiceURL(options.valueOf(jmxServiceUrlOpt))
     val interval = options.valueOf(reportingIntervalOpt).intValue
     val oneTime = interval < 0 || options.has(oneTimeOpt)
-    val attributesWhitelistExists = options.has(attributesOpt)
-    val attributesWhitelist = if(attributesWhitelistExists) Some(options.valueOf(attributesOpt).split(",").filterNot(_.equals("")))
else None
+    val attributesIncludeExists = options.has(attributesOpt)
+    val attributesInclude = if(attributesIncludeExists) Some(options.valueOf(attributesOpt).split(",").filterNot(_.equals("")))
else None
     val dateFormatExists = options.has(dateFormatOpt)
     val dateFormat = if(dateFormatExists) Some(new SimpleDateFormat(options.valueOf(dateFormatOpt)))
else None
     val wait = options.has(waitOpt)
@@ -190,7 +190,7 @@ object JmxTool extends Logging {
     }
 
     val numExpectedAttributes: Map[ObjectName, Int] =
-      if (!attributesWhitelistExists)
+      if (!attributesIncludeExists)
         names.map{name: ObjectName =>
           val mbean = mbsc.getMBeanInfo(name)
           (name, mbsc.getAttributes(name, mbean.getAttributes.map(_.getName)).size)}.toMap
@@ -200,10 +200,10 @@ object JmxTool extends Logging {
             val mbean = mbsc.getMBeanInfo(name)
             val attributes = mbsc.getAttributes(name, mbean.getAttributes.map(_.getName))
             val expectedAttributes = attributes.asScala.asInstanceOf[mutable.Buffer[Attribute]]
-              .filter(attr => attributesWhitelist.get.contains(attr.getName))
+              .filter(attr => attributesInclude.get.contains(attr.getName))
             (name, expectedAttributes.size)}.toMap.filter(_._2 > 0)
         else
-          queries.map((_, attributesWhitelist.get.length)).toMap
+          queries.map((_, attributesInclude.get.length)).toMap
       }
 
     if(numExpectedAttributes.isEmpty) {
@@ -211,7 +211,7 @@ object JmxTool extends Logging {
     }
 
     // print csv header
-    val keys = List("time") ++ queryAttributes(mbsc, names, attributesWhitelist).keys.toArray.sorted
+    val keys = List("time") ++ queryAttributes(mbsc, names, attributesInclude).keys.toArray.sorted
     if(reportFormatOriginal && keys.size == numExpectedAttributes.values.sum + 1)
{
       println(keys.map("\"" + _ + "\"").mkString(","))
     }
@@ -219,7 +219,7 @@ object JmxTool extends Logging {
     var keepGoing = true
     while (keepGoing) {
       val start = System.currentTimeMillis
-      val attributes = queryAttributes(mbsc, names, attributesWhitelist)
+      val attributes = queryAttributes(mbsc, names, attributesInclude)
       attributes("time") = dateFormat match {
         case Some(dFormat) => dFormat.format(new Date)
         case None => System.currentTimeMillis().toString
@@ -249,13 +249,13 @@ object JmxTool extends Logging {
     }
   }
 
-  def queryAttributes(mbsc: MBeanServerConnection, names: Iterable[ObjectName], attributesWhitelist:
Option[Array[String]]): mutable.Map[String, Any] = {
+  def queryAttributes(mbsc: MBeanServerConnection, names: Iterable[ObjectName], attributesInclude:
Option[Array[String]]): mutable.Map[String, Any] = {
     val attributes = new mutable.HashMap[String, Any]()
     for (name <- names) {
       val mbean = mbsc.getMBeanInfo(name)
       for (attrObj <- mbsc.getAttributes(name, mbean.getAttributes.map(_.getName)).asScala)
{
         val attr = attrObj.asInstanceOf[Attribute]
-        attributesWhitelist match {
+        attributesInclude match {
           case Some(allowedAttributes) =>
             if (allowedAttributes.contains(attr.getName))
               attributes(name.toString + ":" + attr.getName) = attr.getValue


Mime
View raw message