Java에서 매우 새롭고 포인터 또는 두 개에 대해 감사하게 생각합니다. 내 자식 커밋에서 부분 텍스트를 저장할 배열 목록을 작성 중입니다. 나는 다음 수행 할 작업을ArrayList에있는 문자열의 고유 한 인스턴스
def commits = sh script: """ git log ${previous_tag}..HEAD --oneline --decorate""", returnStdout: true
def array = commits.split("\\n");
ArrayList<String> mystats = new ArrayList<>(array.length);
for(int i =0; i < array.length; i++) {
Pattern pattern = Pattern.compile("^\\w{7}\\s(MYSTATS-|mystats-)");
Matcher matcher = pattern.matcher(array[i]);
if(matcher.find()) {
mystats.add(array[i])
}
}
가 HashSet의가 가장 좋은 방법입니다 조언 된 고유 한 값을 유지 (그래서 아무것도 중복되지 않음) 및 다른 배열을 만드는 것입니다 젠킨스 내에서 그루비 스크립트에서이 작업을 실행하고 발생한 예외 :이 실행되면이 중복 값
// Put all unique mystats matches into a set
Set<String> mystats_set = new HashSet<String>(mystats.size());
for(int i =0; i < mystats.size(); i++) {
Pattern pattern = Pattern.compile("(MYSTATS-|mystats-)\\w+");
Matcher matcher = pattern.matcher(mystats[i]);
if(matcher.find()) {
String id = matcher.group().toUpperCase().toString();
def jira_json = sh script: '''curl --cert ../certs/dev_cert.p12:password https://jira.dev.organisation.co.uk:port_number/rest/api/2/issue/${id}''', returnStdout: true
mystats_set.add("[" + id + "](https://jira.dev.organisation.co.uk/browse/" + id + ")");
}
}
을 거부합니다으로 난으로 인한
java.io.NotSerializableException: java.util.regex.Matcher
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at java.util.HashMap.internalWriteEntries(HashMap.java:1785)
at java.util.HashMap.writeObject(HashMap.java:1362)
at sun.reflect.GeneratedMethodAccessor202.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at java.util.TreeMap.writeObject(TreeMap.java:2438)
at sun.reflect.GeneratedMethodAccessor204.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:132)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:429)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:408)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:356)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
얻을 필드 지역 주민을에 필드 스레드 필드 프로그램 필드 전자 필드 발신자 필드 부모 에 617,451,515,객체에 는 Set
이 아닌 것 같다 읽기 일부 후에
그래서
을 [email protected] 직렬화 할 수 있습니까? 이 경우 어떻게하면 고유 값만 보유하고 중복 항목을 거부하는 ArrayList를 가질 수 있습니까?어떤 도움은 이제 전체 스택 트레이스를 추가 한 후이 Matcher
이
감사
어디에서 직렬화 프로세스가 발생했는지, 앱이 어디에서 '설정'을 직렬화하려했는지, 그러나 arraylist에 추가하기 전에 arraylist.contains (str)로 확인할 수 있습니다. 그게 네가 필요한거야? – Yazan
이것은 코어 자바처럼 보이지 않습니다. 그루비 또는 스칼라 (또는 다른 것)를 사용하는 경우 적절하게 태그를 지정하십시오. 그리고 당신이 컬렉션의 항목을 직렬화하여 파일에 저장하려고하는 것처럼 보이는 예외는 보이지 않습니까? 어떤 컬렉션이고 Matcher가 포함 된 이유는 무엇입니까? – Tom
@tom, 사과, 네 groovy 사용, 태그 추가, 파일에 쓰려고하지 않음, Ruby의 문자열 보간법과 같은 변수 세트로 각 항목을 사용할 수 있기를 원함 – Richlewis