Skip to content

Commit

Permalink
Merge branch 'master' into praneesha-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
praneesha authored Nov 9, 2023
2 parents bcf77f1 + 4f4b7fd commit 224f0e8
Show file tree
Hide file tree
Showing 47 changed files with 662 additions and 176 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ You can use the following resources to learn Ballerina.

>**Tip:** If you are unsure whether you have found a bug, search the existing issues in the GitHub repo and raise it in the [Ballerina Discord](https://discord.com/invite/wAJYFbMrG2) or [Stack Overflow](https://stackoverflow.com/questions/tagged/ballerina).
- Language, tooling, website: <a href="https://github.com/ballerina-platform/ballerina-lang/issues">ballerina-lang</a> repo
- Ballerina library: <a href="https://github.com/ballerina-platform/ballerina-library/issues">ballerina-library</a> repo
- Language, Tooling, Website: <a href="https://github.com/ballerina-platform/ballerina-lang/issues">ballerina-lang</a> repo
- Ballerina library: <a href="https://github.com/ballerina-platform/ballerina-standard-library/issues">ballerina-library</a> repo
- Security flaw: send an email to security@ballerina.io. For details, see the <a href="https://ballerina.io/security-policy/">security policy</a>.

## Contribute to Ballerina
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private String getXmlNsUriPrefix(Map<String, String> nsPrefixMap, String uri) {
}

private void writeAttributes(HashSet<String> curNSSet, Map<String, String> attributeMap) throws XMLStreamException {
String defaultNS = xmlStreamWriter.getNamespaceContext().getNamespaceURI(XMLNS);
String defaultNS = xmlStreamWriter.getNamespaceContext().getNamespaceURI("");
for (Map.Entry<String, String> attributeEntry : attributeMap.entrySet()) {
String key = attributeEntry.getKey();
int closingCurlyPos = key.lastIndexOf('}');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public class TableValueImpl<K, V> implements TableValue<K, V> {
private long maxIntKey = 0;

//These are required to achieve the iterator behavior
private LinkedHashMap<Long, K> indexToKeyMap;
private LinkedHashMap<Long, Long> indexToKeyMap;
private LinkedHashMap<Long, Long> keyToIndexMap;
private LinkedHashMap<K, V> keyValues;
private LinkedHashMap<Long, KeyValuePair<K, V>> keyValues;
private long noOfAddedEntries = 0;

private boolean nextKeySupported;
Expand Down Expand Up @@ -478,9 +478,11 @@ private class TableIterator<K, V> implements IteratorValue {

@Override
public Object next() {
K key = (K) indexToKeyMap.get(cursor);
if (key != null) {
V value = (V) keyValues.get(key);
Long hash = indexToKeyMap.get(cursor);
if (hash != null) {
KeyValuePair<K, V> keyValuePair = (KeyValuePair<K, V>) keyValues.get(hash);
K key = keyValuePair.getKey();
V value = keyValuePair.getValue();

List<Type> types = new ArrayList<>();
types.add(TypeChecker.getType(key));
Expand Down Expand Up @@ -534,7 +536,7 @@ public V putData(V data) {
entries.put(hash, entryList);
updateIndexKeyMappings((K) data, hash);
values.put(hash, newData);
keyValues.put((K) data, data);
keyValues.put(hash, KeyValuePair.of((K) data, data));
return data;
}

Expand Down Expand Up @@ -588,7 +590,7 @@ public void addData(V data) {
extEntries.add(entry);
List<V> extValues = values.get(hash);
extValues.add(data);
keyValues.put(key, data);
keyValues.put(hash, KeyValuePair.of(key, data));
updateIndexKeyMappings(key, hash);
return;
}
Expand Down Expand Up @@ -630,14 +632,13 @@ public V putData(K key, V data) {
}

private V putData(K key, V value, List<V> data, Map.Entry<K, V> entry, Long hash) {

List<Map.Entry<K, V>> entryList = new ArrayList<>();
entryList.add(entry);
entries.put(hash, entryList);
keys.put(hash, key);
updateIndexKeyMappings(key, hash);
values.put(hash, data);
keyValues.put(key, value);
keyValues.put(hash, KeyValuePair.of(key, value));
return data.get(0);
}

Expand All @@ -655,8 +656,8 @@ public V putData(V data) {
}

public V remove(K key) {
keyValues.remove(key);
Long hash = TableUtils.hash(key, null);
keyValues.remove(hash);
List<Map.Entry<K, V>> entryList = entries.get(hash);
if (entryList != null && entryList.size() > 1) {
for (Map.Entry<K, V> entry: entryList) {
Expand Down Expand Up @@ -747,11 +748,33 @@ public K wrapKey(MapValue data) {
}
}

private static final class KeyValuePair<K, V> {
private K key;
private V value;

public KeyValuePair(K key, V value) {
this.key = key;
this.value = value;
}

public static <K, V> KeyValuePair<K, V> of(K key, V value) {
return new KeyValuePair<>(key, value);
}

public K getKey() {
return key;
}

public V getValue() {
return value;
}
}

// This method updates the indexes and the order required by the iterators
private void updateIndexKeyMappings(K key, Long hash) {
if (!keyToIndexMap.containsKey(hash)) {
keyToIndexMap.put(hash, noOfAddedEntries);
indexToKeyMap.put(noOfAddedEntries, key);
indexToKeyMap.put(noOfAddedEntries, hash);
noOfAddedEntries++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ private BError createXMLCycleError() {
}

private void mergeAdjoiningTextNodesIntoList(List leftList, List<BXml> appendingList) {
XmlPi lastChild = (XmlPi) leftList.get(leftList.size() - 1);
String firstChildContent = ((XmlPi) appendingList.get(0)).getData();
String mergedTextContent = lastChild.getData() + firstChildContent;
XmlText lastChild = (XmlText) leftList.get(leftList.size() - 1);
String firstChildContent = appendingList.get(0).getTextValue();
String mergedTextContent = lastChild.getTextValue() + firstChildContent;
XmlText text = new XmlText(mergedTextContent);
leftList.set(leftList.size() - 1, text);
for (int i = 1; i < appendingList.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@ private static void pullPackageFromRemote(String orgName, String packageName, St
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(),
getAccessTokenOfCLI(settings));
getAccessTokenOfCLI(settings), settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
try {
client.pullPackage(orgName, packageName, version, destination, supportedPlatform,
RepoUtils.getBallerinaVersion(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ private void deprecateInCentral(String packageInfo) {
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(),
getAccessTokenOfCLI(settings));
getAccessTokenOfCLI(settings), settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
client.deprecatePackage(packageValue, deprecationMsg,
JvmTarget.JAVA_17.code(),
RepoUtils.getBallerinaVersion(), this.undoFlag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ public void execute() {
try {
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(), getAccessTokenOfCLI(settings));
settings.getProxy().password(), getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
client.pullPackage(orgName, packageName, version, packagePathInBalaCache, supportedPlatform,
RepoUtils.getBallerinaVersion(), false);
if (version.equals(Names.EMPTY.getValue())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ public void execute() {
}
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(), getAccessTokenOfCLI(settings));
settings.getProxy().password(), getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
if (balaPath == null) {
pushPackage(project, client);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ private void searchInCentral(String query) {
initializeProxy(settings.getProxy()),
settings.getProxy().username(),
settings.getProxy().password(),
getAccessTokenOfCLI(settings));
getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(),
settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
boolean foundSearch = false;
String supportedPlatform = Arrays.stream(JvmTarget.values())
.map(target -> target.code())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,10 @@ private void pullToolFromCentral(String supportedPlatform, Path balaCacheDirPath
System.setProperty(CentralClientConstants.ENABLE_OUTPUT_STREAM, "true");
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(), getAccessTokenOfCLI(settings));
settings.getProxy().password(), getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
String[] toolInfo = client.pullTool(toolId, version, balaCacheDirPath, supportedPlatform,
RepoUtils.getBallerinaVersion(), false);
boolean isPulled = Boolean.parseBoolean(toolInfo[0]);
Expand Down Expand Up @@ -574,7 +577,10 @@ private void searchToolsInCentral(String keyword) {
}
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(), getAccessTokenOfCLI(settings));
settings.getProxy().password(), getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
boolean foundTools = false;
String supportedPlatform = Arrays.stream(JvmTarget.values())
.map(JvmTarget::code)
Expand Down Expand Up @@ -726,7 +732,10 @@ private String getLatestVersionForUpdateCommand(String supportedPlatforms, BalTo
System.setProperty(CentralClientConstants.ENABLE_OUTPUT_STREAM, "true");
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(), getAccessTokenOfCLI(settings));
settings.getProxy().password(), getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
List<String> versions = client.getPackageVersions(tool.org(), tool.name(), supportedPlatforms,
RepoUtils.getBallerinaVersion());
return getLatestVersion(versions, tool.version());
Expand Down
12 changes: 10 additions & 2 deletions cli/ballerina-cli/src/main/resources/new_cmd_defaults/gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
target
generated
# Ballerina generates this directory during the compilation of a package.
# It contains compiler-generated artifacts and the final executable if this is an application package.
target/

# Ballerina maintains the compiler-generated source code here.
# Remove this if you want to commit generated sources.
generated/

# Contains configuration values used during development time.
# See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details.
Config.toml
Loading

0 comments on commit 224f0e8

Please sign in to comment.