Skip to content

Commit b1f7346

Browse files
simon824imbajin
andauthored
chore: fix StringEncoding license & add multi license check action (#227)
* add license check action & use proper "UTF-8" charset * exclude generate go files * include release-docs in binary release * Update NOTICE --------- Co-authored-by: imbajin <jin@apache.org>
1 parent 3d67f38 commit b1f7346

File tree

14 files changed

+316
-64
lines changed

14 files changed

+316
-64
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: hugegraph-computer ci
1+
name: "hugegraph-computer ci"
22

33
on:
44
push:
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
computer-ci:
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-latest
1313
env:
1414
TRAVIS_DIR: computer-dist/src/assembly/travis
1515
KUBERNETES_VERSION: 1.20.1
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
fetch-depth: 2
2323

24-
- name: Install JDK 8
24+
- name: Install JDK 8 for HDFS
2525
uses: actions/setup-java@v3
2626
with:
2727
java-version: '8'

.github/workflows/license-checker.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: "license checker"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- /^release-.*$/
8+
pull_request:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
check-license-header:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
# More info could refer to: https://github.com/apache/skywalking-eyes
20+
- name: Check License Header
21+
uses: apache/skywalking-eyes@main
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
with:
25+
log: info
26+
config: .licenserc.yaml
27+
28+
- uses: actions/setup-java@v3
29+
with:
30+
java-version: '11'
31+
distribution: 'adopt'
32+
33+
- name: License check(RAT)
34+
run: |
35+
mvn apache-rat:check -ntp
36+
find ./ -name rat.txt -print0 | xargs -0 -I file cat file > merged-rat.txt
37+
grep "Binaries" merged-rat.txt -C 3 && cat merged-rat.txt
38+
39+
# TODO: enable it later
40+
# check-dependency-license:
41+
# runs-on: ubuntu-latest
42+
# env:
43+
# SCRIPT_DEPENDENCY: computer-dist/scripts/dependency
44+
# steps:
45+
# - name: Checkout source
46+
# uses: actions/checkout@v3
47+
# - name: Set up JDK 11
48+
# uses: actions/setup-java@v3
49+
# with:
50+
# java-version: '11'
51+
# distribution: 'adopt'
52+
# - name: mvn install
53+
# run: |
54+
# mvn install -DskipTests=true -ntp
55+
# - name: generate current dependencies
56+
# run: |
57+
# bash $SCRIPT_DEPENDENCY/regenerate_known_dependencies.sh current-dependencies.txt
58+
# - name: check third dependencies
59+
# run: |
60+
# bash $SCRIPT_DEPENDENCY/check_dependencies.sh

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Mark stale issues and pull requests
1+
name: "Mark stale issues and pull requests"
22

33
on:
44
schedule:

.licenserc.yaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
header: # `header` section is configurations for source codes license header.
19+
license:
20+
spdx-id: Apache-2.0 # the spdx id of the license, it's convenient when your license is standard SPDX license.
21+
copyright-owner: Apache Software Foundation # the copyright owner to replace the [owner] in the `spdx-id` template.
22+
content: | # `license` will be used as the content when `fix` command needs to insert a license header.
23+
Licensed to the Apache Software Foundation (ASF) under one or more
24+
contributor license agreements. See the NOTICE file distributed with
25+
this work for additional information regarding copyright ownership.
26+
The ASF licenses this file to You under the Apache License, Version 2.0
27+
(the "License"); you may not use this file except in compliance with
28+
the License. You may obtain a copy of the License at
29+
http://www.apache.org/licenses/LICENSE-2.0
30+
Unless required by applicable law or agreed to in writing, software
31+
distributed under the License is distributed on an "AS IS" BASIS,
32+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33+
See the License for the specific language governing permissions and
34+
limitations under the License.
35+
# `pattern` is optional regexp if all the file headers are the same as `license` or the license of `spdx-id` and `copyright-owner`.
36+
pattern: |
37+
Licensed to the Apache Software Foundation under one or more contributor
38+
license agreements. See the NOTICE file distributed with
39+
this work for additional information regarding copyright
40+
ownership. The Apache Software Foundation licenses this file to you under
41+
the Apache License, Version 2.0 \(the "License"\); you may
42+
not use this file except in compliance with the License.
43+
You may obtain a copy of the License at
44+
http://www.apache.org/licenses/LICENSE-2.0
45+
Unless required by applicable law or agreed to in writing,
46+
software distributed under the License is distributed on an
47+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
48+
KIND, either express or implied. See the License for the
49+
specific language governing permissions and limitations
50+
under the License.
51+
paths: # `paths` are the path list that will be checked (and fixed) by license-eye, default is ['**'].
52+
- '**'
53+
54+
paths-ignore: # `paths-ignore` are the path list that will be ignored by license-eye.
55+
- '.gitignore'
56+
- 'LICENSE'
57+
- 'NOTICE'
58+
- 'DISCLAIMER'
59+
- '**/*.md'
60+
- '**/*.versionsBackup'
61+
- '**/*.log'
62+
- '**/*.conf'
63+
- '**/*.txt'
64+
- '**/*.csv'
65+
- '**/*.json'
66+
- '**/*.svg'
67+
- '**/*.gitattributes'
68+
- '**/.flattened-pom.xml'
69+
- '**/.prettierrc'
70+
- '**/*.MF'
71+
- '**/.stylelintrc'
72+
- 'assembly/**'
73+
- '.github/**/*'
74+
- '**/target/*'
75+
- '**/util/StringEncoding.java'
76+
- '**/go.mod'
77+
- '**/go.sum'
78+
comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`.
79+
80+
# license-location-threshold specifies the index threshold where the license header can be located,
81+
# after all, a "header" cannot be TOO far from the file start.
82+
license-location-threshold: 80

LICENSE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,11 @@
200200
See the License for the specific language governing permissions and
201201
limitations under the License.
202202

203+
========================================================================
204+
Apache 2.0 licenses
205+
========================================================================
206+
207+
The following components are provided under the Apache License. See project link for details.
208+
The text of each license is the standard Apache 2.0 license.
209+
210+
computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java files from https://github.com/JanusGraph

NOTICE

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,56 @@ This product includes software developed at
55
The Apache Software Foundation (http://www.apache.org/).
66

77
The initial codebase was donated to the ASF by HugeGraph Authors, copyright 2017-2021.
8+
9+
-----------------------------------------------------------------------
10+
This product contains code form the JanusGraph Project:
11+
-----------------------------------------------------------------------
12+
==============================================================
13+
JanusGraph: Distributed Graph Database
14+
Copyright 2012 and onwards JanusGraph Authors
15+
==============================================================
16+
17+
This product includes software developed by JanusGraph contributors listed
18+
in CONTRIBUTORS.txt; JanusGraph copyright holders are listed in AUTHORS.txt.
19+
20+
This product is based on Titan, originally developed by Aurelius (acquired by
21+
DataStax) and the following individuals:
22+
23+
* Matthias Broecheler
24+
* Dan LaRocque
25+
* Marko A. Rodriguez
26+
* Stephen Mallette
27+
* Pavel Yaskevich
28+
29+
It also includes software from other open source projects including, but not limited to (check pom.xml for complete listing):
30+
31+
* Apache Cassandra [https://cassandra.apache.org/]
32+
* Apache Commons [https://commons.apache.org/]
33+
* Apache Groovy [http://groovy-lang.org/]
34+
* Apache HBase [https://hbase.apache.org/]
35+
* Apache Hadoop [https://hadoop.apache.org/]
36+
* Apache Kerby [https://github.com/apache/directory-kerby]
37+
* Apache Log4j [https://logging.apache.org/log4j]
38+
* Apache Lucene [https://lucene.apache.org/]
39+
* Apache Solr [https://lucene.apache.org/solr/]
40+
* Apache TinkerPop [https://tinkerpop.apache.org/]
41+
* Astyanax [https://github.com/Netflix/astyanax]
42+
* DataStax Driver for Apache Cassandra [https://github.com/datastax/java-driver]
43+
* EasyMock [http://easymock.org/]
44+
* Elasticsearch [https://www.elastic.co/]
45+
* Google Cloud Bigtable [https://github.com/googlecloudplatform/cloud-bigtable-client]
46+
* Google Guava [https://github.com/google/guava]
47+
* HPPC [https://labs.carrotsearch.com/hppc.html]
48+
* JUnit [https://www.junit.org/]
49+
* Jackson [https://github.com/FasterXML/jackson]
50+
* Kryo [https://github.com/EsotericSoftware/kryo]
51+
* Metrics [https://metrics.dropwizard.io]
52+
* Mockito [https://site.mockito.org/]
53+
* Noggit [https://github.com/yonik/noggit]
54+
* OpenRDF [http://rdf4j.org/]
55+
* Oracle BerkeleyDB Java Edition [https://www.oracle.com/technetwork/products/berkeleydb/] (see license below)
56+
* Project Lombok [https://projectlombok.org/]
57+
* Reflections8 [https://github.com/aschoerk/reflections8]
58+
* SLF4J [https://www.slf4j.org/]
59+
* Spatial4j [https://github.com/locationtech/spatial4j]
60+
* Vavr [https://www.vavr.io/]

computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Licensed to the Apache Software Foundation (ASF) under one or more
3-
* contributor license agreements. See the NOTICE file distributed with this
4-
* work for additional information regarding copyright ownership. The ASF
5-
* licenses this file to You under the Apache License, Version 2.0 (the
6-
* "License"); you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14-
* License for the specific language governing permissions and limitations
15-
* under the License.
16-
*/
171
// Copyright 2017 JanusGraph Authors
182
//
193
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,7 +14,7 @@
3014

3115
package org.apache.hugegraph.computer.core.util;
3216

33-
import java.io.UnsupportedEncodingException;
17+
import java.nio.charset.StandardCharsets;
3418
import java.security.MessageDigest;
3519
import java.security.NoSuchAlgorithmException;
3620
import java.util.Base64;
@@ -44,7 +28,6 @@
4428

4529
/**
4630
* @author Matthias Broecheler (me@matthiasb.com)
47-
* @author HugeGraph Authors
4831
*/
4932
public final class StringEncoding {
5033

@@ -63,7 +46,7 @@ public final class StringEncoding {
6346
private static final Base64.Encoder BASE64_ENCODER = Base64.getEncoder();
6447
private static final Base64.Decoder BASE64_DECODER = Base64.getDecoder();
6548

66-
// Similar to {@link StringSerializer}
49+
/** Similar to {@link StringSerializer} */
6750
public static int writeAsciiString(byte[] array, int offset, String value) {
6851
E.checkArgument(CharMatcher.ascii().matchesAllOf(value),
6952
"'%s' must be ASCII string", value);
@@ -79,7 +62,8 @@ public static int writeAsciiString(byte[] array, int offset, String value) {
7962
assert c <= 127;
8063
byte b = (byte) c;
8164
if (++i == len) {
82-
b |= 0x80; // End marker
65+
// End marker
66+
b |= 0x80;
8367
}
8468
array[offset++] = b;
8569
} while (i < len);
@@ -89,7 +73,7 @@ public static int writeAsciiString(byte[] array, int offset, String value) {
8973

9074
public static String readAsciiString(byte[] array, int offset) {
9175
StringBuilder sb = new StringBuilder();
92-
int c = 0;
76+
int c;
9377
do {
9478
c = 0xFF & array[offset++];
9579
if (c != 0x80) {
@@ -106,27 +90,15 @@ public static int getAsciiByteLength(String value) {
10690
}
10791

10892
public static byte[] encode(String value) {
109-
try {
110-
return value.getBytes("UTF-8");
111-
} catch (UnsupportedEncodingException e) {
112-
throw new ComputerException("Failed to encode string", e);
113-
}
93+
return value.getBytes(StandardCharsets.UTF_8);
11494
}
11595

11696
public static String decode(byte[] bytes) {
117-
try {
118-
return new String(bytes, "UTF-8");
119-
} catch (UnsupportedEncodingException e) {
120-
throw new ComputerException("Failed to decode string", e);
121-
}
97+
return new String(bytes, StandardCharsets.UTF_8);
12298
}
12399

124100
public static String decode(byte[] bytes, int offset, int length) {
125-
try {
126-
return new String(bytes, offset, length, "UTF-8");
127-
} catch (UnsupportedEncodingException e) {
128-
throw new ComputerException("Failed to decode string", e);
129-
}
101+
return new String(bytes, offset, length, StandardCharsets.UTF_8);
130102
}
131103

132104
public static String encodeBase64(byte[] bytes) {
@@ -157,8 +129,7 @@ public static UUID uuid(String value) {
157129
return UUID.fromString(value);
158130
}
159131
// UUID represented by hex string
160-
E.checkArgument(value.length() == 32,
161-
"Invalid UUID string: %s", value);
132+
E.checkArgument(value.length() == 32, "Invalid UUID string: %s", value);
162133
String high = value.substring(0, 16);
163134
String low = value.substring(16);
164135
return new UUID(Long.parseUnsignedLong(high, 16),

computer-dist/release-docs/LICENSE

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,8 @@ The following components are provided under the Apache 2.0 License.
410410
(Apache License, Version 2.0) * Xml Compatibility extensions for Jackson(org.codehaus.jackson:jackson-xc:1.9.2-http://jackson.codehaus.org )
411411
(Apache License, Version 2.0) * Javassist(org.javassist:javassist:3.21.0-GA-http://www.javassist.org/ )
412412

413+
computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java files from https://github.com/JanusGraph
414+
413415
========================================================================
414416
Third party BSD licenses
415417
========================================================================
@@ -497,9 +499,9 @@ The following components are provided under the Public Domain License.
497499
(Public Domain, per Creative Commons CC0) * XZ for Java(org.tukaani:xz:1.8-https://tukaani.org/xz/java.html )
498500

499501
========================================================================
500-
Third party Go licens
502+
Third party Go license
501503
========================================================================
502504

503-
The following components are provided under The Go licens.
505+
The following components are provided under The Go license.
504506

505507
(The Go license) * re2j(com.google.re2j:re2j:1.1-http://github.com/google/re2j )

0 commit comments

Comments
 (0)