Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
52d3e4d6
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
52d3e4d6
编写于
3月 20, 2017
作者:
S
Stephan Ewen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[hotfix] Clean up StringUtils and remove unused methods.
上级
fc2325ab
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
11 addition
and
73 deletion
+11
-73
flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/SimpleConsumerThread.java
...ming/connectors/kafka/internals/SimpleConsumerThread.java
+3
-3
flink-core/src/main/java/org/apache/flink/util/StringUtils.java
...core/src/main/java/org/apache/flink/util/StringUtils.java
+8
-63
flink-core/src/test/java/org/apache/flink/util/StringUtilsTest.java
.../src/test/java/org/apache/flink/util/StringUtilsTest.java
+0
-7
未找到文件。
flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/SimpleConsumerThread.java
浏览文件 @
52d3e4d6
...
...
@@ -30,7 +30,7 @@ import kafka.javaapi.message.ByteBufferMessageSet;
import
kafka.message.MessageAndOffset
;
import
org.apache.flink.streaming.util.serialization.KeyedDeserializationSchema
;
import
org.apache.flink.util.
String
Utils
;
import
org.apache.flink.util.
Exception
Utils
;
import
org.apache.kafka.common.Node
;
...
...
@@ -295,7 +295,7 @@ class SimpleConsumerThread<T> extends Thread {
}
else
if
(
code
!=
ErrorMapping
.
NoError
())
{
exception
+=
"\nException for "
+
fp
.
getTopic
()
+
":"
+
fp
.
getPartition
()
+
": "
+
String
Utils
.
stringifyException
(
ErrorMapping
.
exceptionFor
(
code
));
Exception
Utils
.
stringifyException
(
ErrorMapping
.
exceptionFor
(
code
));
}
}
if
(
partitionsToGetOffsetsFor
.
size
()
>
0
)
{
...
...
@@ -502,7 +502,7 @@ class SimpleConsumerThread<T> extends Thread {
if
((
code
=
response
.
errorCode
(
part
.
getTopic
(),
part
.
getPartition
()))
!=
ErrorMapping
.
NoError
())
{
exception
.
append
(
"\nException for topic="
).
append
(
part
.
getTopic
())
.
append
(
" partition="
).
append
(
part
.
getPartition
()).
append
(
": "
)
.
append
(
String
Utils
.
stringifyException
(
ErrorMapping
.
exceptionFor
(
code
)));
.
append
(
Exception
Utils
.
stringifyException
(
ErrorMapping
.
exceptionFor
(
code
)));
}
}
if
(++
retries
>=
3
)
{
...
...
flink-core/src/main/java/org/apache/flink/util/StringUtils.java
浏览文件 @
52d3e4d6
...
...
@@ -38,21 +38,7 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
@PublicEvolving
public
final
class
StringUtils
{
/**
* Empty private constructor to overwrite public one.
*/
private
StringUtils
()
{}
/**
* Makes a string representation of the exception.
*
* @param e
* the exception to stringify
* @return A string with exception name and call stack.
*/
public
static
String
stringifyException
(
final
Throwable
e
)
{
return
ExceptionUtils
.
stringifyException
(
e
);
}
private
static
final
char
[]
HEX_CHARS
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
/**
* Given an array of bytes it will convert the bytes to a hex string
...
...
@@ -65,15 +51,13 @@ public final class StringUtils {
* @param end
* end index, exclusively
* @return hex string representation of the byte array
*
* @see org.apache.commons.codec.binary.Hex#encodeHexString(byte[])
*/
public
static
String
byteToHexString
(
final
byte
[]
bytes
,
final
int
start
,
final
int
end
)
{
if
(
bytes
==
null
)
{
throw
new
IllegalArgumentException
(
"bytes == null"
);
}
final
char
[]
HEX_CHARS
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
int
length
=
end
-
start
;
char
[]
out
=
new
char
[
length
*
2
];
...
...
@@ -114,50 +98,6 @@ public final class StringUtils {
}
return
bts
;
}
/**
* Helper function to escape Strings for display in HTML pages. The function replaces
* certain characters by their HTML coded correspondent.
*
* @param str The string to escape.
* @return The escaped string.
*/
public
static
String
escapeHtml
(
String
str
)
{
int
len
=
str
.
length
();
char
[]
s
=
str
.
toCharArray
();
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
len
;
i
+=
1
)
{
char
c
=
s
[
i
];
if
((
c
==
'\\'
)
||
(
c
==
'"'
)
||
(
c
==
'/'
))
{
sb
.
append
(
'\\'
);
sb
.
append
(
c
);
}
else
if
(
c
==
'\b'
)
{
sb
.
append
(
"\\b"
);
}
else
if
(
c
==
'\t'
)
{
sb
.
append
(
"\\t"
);
}
else
if
(
c
==
'\n'
)
{
sb
.
append
(
"<br>"
);
}
else
if
(
c
==
'\f'
)
{
sb
.
append
(
"\\f"
);
}
else
if
(
c
==
'\r'
)
{
sb
.
append
(
"\\r"
);
}
else
if
(
c
==
'>'
)
{
sb
.
append
(
">"
);
}
else
if
(
c
==
'<'
)
{
sb
.
append
(
"<"
);
}
else
if
(
c
==
'&'
)
{
sb
.
append
(
"&"
);
}
else
if
(
c
<
' '
)
{
// Unreadable throw away
}
else
{
sb
.
append
(
c
);
}
}
return
sb
.
toString
();
}
/**
* This method calls {@link Object#toString()} on the given object, unless the
...
...
@@ -310,7 +250,7 @@ public final class StringUtils {
/**
* Writes a String to the given output.
* The written string can be read with {@link #read
Nullable
String(DataInputView)}.
* The written string can be read with {@link #readString(DataInputView)}.
*
* @param str The string to write
* @param out The output to write to
...
...
@@ -382,4 +322,9 @@ public final class StringUtils {
}
return
true
;
}
// ------------------------------------------------------------------------
/** Prevent instantiation of this utility class */
private
StringUtils
()
{}
}
flink-core/src/test/java/org/apache/flink/util/StringUtilsTest.java
浏览文件 @
52d3e4d6
...
...
@@ -40,13 +40,6 @@ public class StringUtilsTest extends TestLogger {
assertEquals
(
"[1.0]"
,
controlString
);
}
@Test
public
void
testEscapeHTML
()
{
String
testString
=
"\b \t / \n \f \r <default>"
;
String
controlString
=
StringUtils
.
escapeHtml
(
testString
);
assertEquals
(
"\\b \\t \\/ <br> \\f \\r <default>"
,
controlString
);
}
@Test
public
void
testStringToHexArray
()
{
String
hex
=
"019f314a"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录