This commit is contained in:
looly
2021-12-12 12:09:35 +08:00
parent 60901d5815
commit fae914cf48
4 changed files with 31 additions and 11 deletions

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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);
}
}
}
}

View File

@@ -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";