mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix bug
This commit is contained in:
@@ -8,7 +8,8 @@
|
||||
### 🐣新特性
|
||||
### 🐞Bug修复
|
||||
* 【core 】 LineReadWatcher#onModify文件清空判断问题(issue#2013@Github)
|
||||
* 【core 】 修复4位bytes转换float问题(issue#I4M0E4@Github)
|
||||
* 【core 】 修复4位bytes转换float问题(issue#I4M0E4@Gitee)
|
||||
* 【core 】 修复CharSequenceUtil.replace问题(issue#I4M16G@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.7.17 (2021-12-09)
|
||||
|
@@ -3538,6 +3538,11 @@ public class CharSequenceUtil {
|
||||
|
||||
final int strLength = str.length();
|
||||
final int searchStrLength = searchStr.length();
|
||||
if(strLength < searchStrLength){
|
||||
// issue#I4M16G@Gitee
|
||||
return str(str);
|
||||
}
|
||||
|
||||
if (fromIndex > strLength) {
|
||||
return str(str);
|
||||
} else if (fromIndex < 0) {
|
||||
|
@@ -1499,20 +1499,26 @@ public class XmlUtil {
|
||||
*/
|
||||
private void examineNode(Node node, boolean attributesOnly) {
|
||||
final NamedNodeMap attributes = node.getAttributes();
|
||||
final int length = attributes.getLength();
|
||||
for (int i = 0; i < length; i++) {
|
||||
Node attribute = attributes.item(i);
|
||||
storeAttribute(attribute);
|
||||
//noinspection ConstantConditions
|
||||
if (null != attributes) {
|
||||
final int length = attributes.getLength();
|
||||
for (int i = 0; i < length; i++) {
|
||||
Node attribute = attributes.item(i);
|
||||
storeAttribute(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
if (false == attributesOnly) {
|
||||
final NodeList childNodes = node.getChildNodes();
|
||||
Node item;
|
||||
final int childLength = childNodes.getLength();
|
||||
for (int i = 0; i < childLength; i++) {
|
||||
item = childNodes.item(i);
|
||||
if (item.getNodeType() == Node.ELEMENT_NODE)
|
||||
examineNode(item, false);
|
||||
//noinspection ConstantConditions
|
||||
if(null != childNodes){
|
||||
Node item;
|
||||
final int childLength = childNodes.getLength();
|
||||
for (int i = 0; i < childLength; i++) {
|
||||
item = childNodes.item(i);
|
||||
if (item.getNodeType() == Node.ELEMENT_NODE)
|
||||
examineNode(item, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,14 @@ public class CharSequenceUtilTest {
|
||||
Assert.assertEquals("SSMBeryAllen", actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replaceTest2(){
|
||||
// https://gitee.com/dromara/hutool/issues/I4M16G
|
||||
String replace = "#{A}";
|
||||
String result = CharSequenceUtil.replace(replace, "#{AAAAAAA}", "1");
|
||||
Assert.assertEquals(replace, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addPrefixIfNotTest(){
|
||||
String str = "hutool";
|
||||
|
Reference in New Issue
Block a user